Welcome to the SRP Forum! Please refer to the SRP Forum FAQ post if you have any questions regarding how the forum works.

HTTP status code 200 with message

If I do this:
HTTP_Services('SetResponseStatus', 200, ItemID:' was found in Users. But it is non current.')
Is the 'message' part retrievable by the web developer? If so, do you know how?

Comments

  • This is dependent upon the web server. If you don't see it in Postman then your web developer won't see it either. There isn't anything you can do in the web API code since it is packaging the code and response text properly in the response.
  • I'd also be wondering if a web developer would be looking for a message, especially with a status of 200.
    I know in our case, I had to tell the web guy which specific codes to be on the lookout for if they needed to do something different. Otherwise, they just kind of went 'worked', 'didn't work' regardless of what message I was sending back.
  • HTTP messaging is meant to be both machine and human readable. Web developers ought to be relying upon the codes as they are programming a machine. If the human readable content is ultimate meant for an end user to see, I would recommend storing it in the response body.
  • edited May 2017
    Well, who is supposed to see the message part of the status code return if it is not the user?
  • If the web server passes it through, the client is meant to see it. It's not wrong for the client to then use this to help provide additional messages to the end user, but it is not a reliable solution. If you see your own messages returned in Postman then your web developer should see them as well. Regardless, when I review REST API documentation from other companies, I almost always see that they embed the status phrase within the response body. This is one of the ways to implement the self-descriptive messaging constraint a prescribed by REST. The SRP HTTP Framework will actually build a default JSON response body if you don't specify any body text.
Sign In or Register to comment.