Why does the response have a status of 200 but a status code of 406?

197    Asked by darsh_6738 in Salesforce , Asked on Aug 17, 2023

I am trying to pass a session ID and one parameter having a unique ID. But the output is not what I expected. I have a simple API on Salesforce, which can return simple user data. But it is showing that the HTTP status and statusCode are different from each other. Why is that happening? What can be done to make those the same? 

Answered by Diane Carr

 When the status code 200 and the status code 406 occur, there are usually two different codes. For example, 200 refers to the response code, which can be used by writing response.statusCode. This code implies that the request was successful and was processed by the server, showing a successful response. However, the 406 on the response header may look inaccessible.

But most of the time, if you want your status and status code to be the same, you must take care of what you want to pass in response.header.statusCode() and response.statusCode(). Usually, keeping the value the same solves the issue entirely.



Your Answer

Interviews

Parent Categories