babicbla
babicbla

Reputation: 1

How to POST a new entry in JSON Format at OData-Service with POSTMAN?

This is my OData-Service.

Both read and write are allowed. The GET-Method is working fine, but I am not able to POST something new. I Want to POST a new entry with POSTMAN.


(POST-Method) 
Link: http://services.odata.org/V3/(S(blacksheep))/OData/OData.svc/Products
Auth: NoAuth
Headers: Content-Type = application/json
Body (raw JSON):
{   
    "ID": "11",
    "Name": "Lern-CD",
    "Description": "Lerne die Theorie in 10 Minuten!",
    "ReleaseDate": "1995-10-01T00:00:00",
    "DiscontinuedDate": "1995-10-01T00:00:00",
    "Rating": 1,
    "Price": 22
}

The error message is:

Error processing request stream. Type information must be specified for types that take part in inheritance.

Does anyone know what is missing here? Do I need to give additional information at the headers? Or something else?

I tried so many things, but I was not able to find the solution.. :/

Upvotes: 0

Views: 7378

Answers (1)

jps
jps

Reputation: 22545

You need to add the odata.type to the json body, in your case Product which is defined in the namespace ODataDemo:

{  "odata.type" :"ODataDemo.Product",
   "ID": "11",
   "Name": "Lern-CD",
   "Description": "Lerne die Theorie in 10 Minuten!",
   "ReleaseDate": "1995-10-01T00:00:00",
   "DiscontinuedDate": "1995-10-01T00:00:00",
   "Rating": 1,
   "Price": 22
}

With this request, you should be able to get a 201 - created Http response. Find more information at https://blogs.msdn.microsoft.com/leohu/2013/10/04/odata-and-json-payload-examples/

Upvotes: 2

Related Questions