I have a requirment to integrate a .net system with Salesforce using REST API. In that I need to show a proper error message on request payload error.

From .net system I get proper error status like "400 BillingAddress is not complete", tested this in "Advance REST client" in Chrome. enter image description here

But in Salesforce I get the response like "System.HttpResponse[Status=Bad Request, StatusCode=400]".

I am getting a correct StatusCode but not Status. Used getStatus() method and getBody() method. Can anyone please let me know how to get the Status using REST API.

  • so you don't see the "BillingAddress is not complete" at all in the response? – Salesforce Learner Sep 8 '15 at 14:44
  • yes I couldn't see in any part of response.. – vicky90 Sep 14 '15 at 4:43

I resolved this by changing in API end by sending the error message as JSON response. By default Salesforce shows only default message for respective Status Code.

In my case I'm getting a response with status code as 400 and Salesforce set the status message as "Bad Request". So I changed in my API end to send a JSON response with error message, from that I can show a proper error message in Salesforce.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.