5

I have a REST API Endpoint endpoint/action. The method is POST having a json data in the request body. I have two headers for this

  1. Content-Type=application/json
  2. Custom-Header={"object":{"id":"someId"}}

The object is deserialized during processing and the "someId" is used for other processes

Was wondering if it is a good practice to send json strings/data in the http header. Couldn't find anything in the Http Header documentations. Option would be just sending in the "someId" and fetching the object using the id

Bhagyashree Jog
  • 90
  • 3
  • 12
  • Possible duplicate of [REST APIs: custom HTTP headers vs URL parameters](http://stackoverflow.com/questions/9169081/rest-apis-custom-http-headers-vs-url-parameters) – Alexandru Marculescu Jun 01 '16 at 06:51
  • @AlexandruMarculescu Dont think so. The post you've stated asks if the parameter should be sent in query param or the header. I'm sure I have to send the someId in the header. Just not sure if sending in the entire json would be a good practice. Should it be sent as just someId or sending it as the json data stated would be fine – Bhagyashree Jog Jun 01 '16 at 07:03
  • Similar question: https://stackoverflow.com/questions/9779860/using-json-string-in-the-http-header – Ali Ok Oct 22 '18 at 12:13

0 Answers0