Search code examples
javaodata

OData POST Response


I am giving request to OData POST in Json format and it's returning the same request to me.

POST URL= http://localhost:8085/MagicXpiOData/Odata_get.OData_1/Student_details

Body:

{"Division": "Nashik"}  
Content-Type = application/json

Response:

{ 
  "@odata.context": "$metadata#Student_details",
  "Division": "Nashik"
}

Is this a correct response? I think it should return a status code for success or not.


Solution

  • What you show above is the response body, which usually contains the OData.Context. Beside that you should find the HTTP Status Code in the header, which might be something like

    HTTP/1.1 200 OK
    HTTP/1.1 201 Created
    

    and when you create a new entry also a location header.

    Some examples that show typical requests and responses can be found in this Basic Tutorial

    So generally your response looks ok. Maybe you can add the response header in your question, then we can see if everything is there what should be there.

    When you send your request with a tool like Postman or Fiddler, you might by default only see the response body. To see the headers you need to switch to Headers, or Raw in Fiddler to see the full response (header and body).