APIs & Integrations

bgsueeid
Participant

View full body of request

Is it possible to view the full body of an previously made API request?  I sometimes receive an error message like the following: "Invalid input JSON on line 1, column 160983."  It would be helpful to see what the exact request body was so I can see what triggered the error.

 

I can view part of the body in the Call Details slideout from the logs of the private app that I'm calling.  However, only the first 2000 characters of the request body are shown, and clicking the Copy button only copies those 2000 characters to the clipboard.  If the problem is after the first 2000 characters, I can't identify the cause.

 

I'm using the PHP library to construct API calls, so I'm not building the request myself, which is why I'm seeking a way to view the raw request.

 

I'm fine with either calling an API function to get the full request body (perhaps using the Request ID) or using something within HubSpot itself; I'm just hoping that there's a way to get the full request to help with debugging.

 

2 Replies 2
Jaycee_Lewis
Community Manager
Community Manager

View full body of request

Hi, @bgsueeid 👋 Great question. Outside the initial 2000 characters, you'll need to modify your code to log the request body to a file or a debugging tool just before it's sent.

 

Best,

Jaycee







HubSpot’s AI-powered customer agent resolves up to 50% of customer queries instantly, with some customers reaching up to 90% resolution rates.


Learn More.





Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !
0 Upvotes
bgsueeid
Participant

View full body of request

Hi, Jaycee.  Thank you for your response.

 

Is there a way to get the request body when using the PHP client library?  The library encapsulates details such as crafting the actual request body and I am not aware of a way to get the request body that will be generated before it is actually sent.

 

For instance, if I want to create a contact, I would issue a command like the following:

 

$apiResponse = $client->crm()->contacts()->batchApi()->create($batchInputSimplePublicObjectInputForCreate);

 

The create() method returns the response from the server to the request.  But it doesn't appear that I have a way to get that request before it is sent, unless there is something akin to a "last request sent" global variable or property of the client.

 

0 Upvotes