Infusionsoft exception

Hello, guys, I need to log the exception that I get when trying to save data on infusion soft via API. The problem is you guys are returning me a string which has stacktrace with it which is of no use to me. I just need to get the error message. Can you guys please help me out

and one more thing the error code that you are sending is 0 but in the message, it is 400. Can you guys please tell me how to resolve it thanks

Below I’ve attached a image. Please help me out thanks
[image removed due to access token]

Hi @Rohan_Jalil, we have removed your uploaded image because it included your access token. For future reference, please be sure to obscure the access token in a screenshot or exclude it when pasting code or errors. I would also recommend refreshing your access token so that your current one will no longer be valid.

That being said, I would love to help with the error you’re receiving. Can you please post the snippet of code or an example request that is causing this error?

@Nicholas_Trecina Thanks . Well the only problem that I’m facing is the exception that is returned from the API when I’m trying to save the data contains everything in the message (the code, the stacktrace and the message)

I need to keep the record why was I not able to save contacts on your system. and for that I need to get the error code from the code field and the message from the message field and not the stacktrace from it Can you guys please tell me. I’m posting and I’ve removed the access token from it.

Here is the code

\Log::debug("The error code is : ". $e->getCode());
\Log::debug("The error message is : ". \GuzzleHttp\json_decode($e->getMessage()));

and this returns this

When I try to get the error code it gives me 0 and when I try to get the message why it was failed it gives me the stacktrace which I do not require.

Can you guys please help me out. Thanks

@Nicholas_Trecina This is what I’m getting when I dump the mesage. I just need the message not the stacktrace with it

@Nicholas_Trecina guys any help ???

Have you attempted to try this in Postman? Way easier to diagnose than text/CLI

Rohan, there are two issues I see here:

First, the response you are getting is indeed a 400 (“Bad Request”), which generally means that the request body couldn’t be coerced into an object in the endpoint. I’d recommend posting your payload here so that we can compare it to the docs, or to try using the interactive docs to post that content from there.

Second, the PHP library that you are using (“guzzlehttp”?) seems to be throwing an exception and generating a stack trace. That’s not coming from us, as you can see our JSON response on the first line.