NetTalk Central

Author Topic: NetWebService - HTTP status codes for REST  (Read 4266 times)

Thys

  • Sr. Member
  • ****
  • Posts: 311
    • View Profile
    • Incasu
    • Email
NetWebService - HTTP status codes for REST
« on: September 26, 2018, 09:24:29 PM »
Hi,

One of the REST guidelines is the use of HTTP status codes for better communication, not just for 200 OK or 404 Page Not Found. I've noticed that, although NT has a SendError method with which this status code can be set, most of the normal responses are handled nicely by NT.

To be able to build in more meaning in responses using the status codes, will the SendError method be the best to use? Examples could be 202 Accepted, 206 Partial Content, 301 Moved Permanently etc. - all of which may benefit the comms with clients.

Thanks
Thys

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: NetWebService - HTTP status codes for REST
« Reply #1 on: September 30, 2018, 10:08:25 PM »
Hi Thys,

I think the key answer here is that it depends on the code you want to send, and in what context. The codes are obviously very different and so each would need to be dealt with on an individual basis.
(redirection codes, 30x for example are quite different to 20x codes.)

You should also be very careful what codes you use - 206 for example (partial content) is to do with Ranges and is handled/used internally. That would not be a good code to re-appropriate. But a 201 (Created) might be a good reply to an Insert etc.

There is a property p_web.ReplyResponseNumber which you can set. Just be careful which ones you use, and what you set them for. You might want to post your suggestions here before locking them in stone.

cheers
Bruce