Skip to Content
0

Problem with POST method in ODATA API

Feb 05 at 05:13 PM

70

avatar image

Hi,


I have a problem regarding to POST method in ODATA service

I need to use one of the following POST/PUT/PATCH method in order to change a parameter (name of Ticket) or create new entity for Service request(Ticket)

This is my JSON format:

But when i Execute it, I recieve this message:

Uknown error. Please check the metadata and try again!

Could anyone help me how should be the format of POST or PUT?

I have tried in so many different ways and I am totally blocked :(

Regards
Sin

screenshot-12.png (33.9 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Marlos Augustus Maciel Damasceno Feb 05 at 06:38 PM
1

Hi S Sin,

You may use only PATCH to update an object, I had some issues using PUT.

Anyway, you does not need to pass the metadata in the payload of your request. Moreover, the url cannot be $?filter=ID eq '2' this must be replaced by the UUID, just like is in the uri of your payload ('00163E03A0101ED28A8644CF8D83AE76').

Something like this:

Method: PATCH
URL: https://myxxxxx.crm.ondemand.com/sap/byd/odata/cust/v1/custom_ticketodata/ServiceRequestColletion('UUID_of_Object')
Payload: JSON


"d" : {
	"ID" : "id of Object",
	"Name": "Name of Object"
}

Best regards,

Marlos Damasceno

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks Marlos Damasceno,

It worked for me

This is my JSON file

{
  "d": 
{ "uri": "https://myxxxxx.crm.ondemand.com/sap/byd/odata/cust/v1/custom_ticketodata/ServiceRequestCollection('00163E03A0701ED28A8644CF8D83AE76')",
"type": "cust.ServiceRequest",
"etag": "W/\"datetimeoffset'2012-11-06T16%3A51%3A55.1323330Z'\"",
"Payload": "JSON" },
"Name": "ChangedName",
"ETag": "/Date(1352220715132)/",
"ObjectID": "00163E03A0701ED28A8644CF8D83AE76" }
1