My Business
3.2K members online now
3.2K members online now
For developers who are using the Google My Business API to manage locations
Guide Me
star_border
Reply

How to add additional header in the request?

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi all,

 

I need more error details in the API response for the GMB API and I saw this:

 

Detailed Error Responses

To enable more detailed error messages in responses (including missing required fields), add this additional header to your requests:

X-GOOG-API-FORMAT-VERSION: 2

 

https://developers.google.com/my-business/content/support#detailed_error_responses

 

How can I add the additional header in the request?

 

Thank you,

Andrei

2 Expert replyverified_user

Re: How to add additional header in the request?

[ Edited ]
Google Employee
# 2
Google Employee

Hi @Andrei C,

Generally, we add HTTP header fields as they provide required information about the request or response, or about the object sent in the message body. Their usual format is: "Header name: Header value".

 

Detailed error messages are enabled by default in OAuth 2.0 Playground.

 

If you are working with Java client libraries, you can add  ‘X-GOOG-API-FORMAT-VERSION: 2’ in your Java code (as shown in Java sample app) to enable more detailed error messages.

Thanks,
The Google My Business API team

Re: How to add additional header in the request?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
My question was how to add the header to the API, not at the Playground.
My solution is to extend the call method from Google_Service_Resource in Google API Client and add the header in the headers array.

Re: How to add additional header in the request?

Google Employee
# 4
Google Employee

Hi @Andrei C,

 

Please note that adding an additional header to HTTP requests when using the PHP client library and the Google API Client Library for PHP is not officially supported at this time. Therefore, the PHP client library doesn’t currently support the display of detailed error messages. Currently, only the Java client library supports adding an additional header to HTTP requests for enabling more detailed error messages in responses. We are aware of this scenario when using the PHP client library and will notify you on this board once we support this functionality.

 

Thanks,

Terry