I'm trying deepinsert with Json on the service,http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/OData/OData.svc/Categories with body--
{
"d" : {
"__metadata": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Categories(0)", "type": "ODataDemo.Category"
}, "ID": 97, "Name": "Food", "Products": [
{
"__metadata": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Products( 0)", "type": "ODataDemo.Product"
}, "ID": 97, "Name": "Bread", "Description": "Whole grain bread", "ReleaseDate": "\/Date(694224000000)\/", "DiscontinuedDate": null, "Rating": 4, "Price": "2.5", "Category": {
"__deferred": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Products(0)/Category"
}
}, "Supplier": {
"__deferred": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Products(0)/Supplier"
}
}
}
]
}
}
and I get the 400 Bad request with error description:
{
error: {
code: ""
message: {
lang: "en-US"
value: "Error processing request stream. The property name 'd' specified for type 'ODataDemo.Category' is not valid."
}-
}-
}
Can someone help me figure out what I'm doing wrong here?
There is no need to append "d" in the body of post request. Remove the "d" and send the body like this:
{
"__metadata": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Categories(0)", "type": "ODataDemo.Category"
}, "ID": 97, "Name": "Food", "Products": [
{
"__metadata": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Products( 0)", "type": "ODataDemo.Product"
}, "ID": 97, "Name": "Bread", "Description": "Whole grain bread", "ReleaseDate": "\/Date(694224000000)\/", "DiscontinuedDate": null, "Rating": 4, "Price": "2.5", "Category": {
"__deferred": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Products(0)/Category"
}
}, "Supplier": {
"__deferred": {
"uri":"http://services.odata.org/(S(egpbfjhhvili4slwaq1p2lvt))/V2/odata/OData.svc/Products(0)/Supplier"
}
}
}
]
}