cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to get Json format response for Post method call for C4C odata API

former_member690694
Participant
0 Likes
4,833

Dear Team,

I need to post method call response in json format i have tried below format like get call but it's not supporting for post method call for any c4c odata api like Contactcollection. Could you please guide me how to get it. By defalut it's giving XML response successful but in same way we need in json format.

https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ContactCollection?$format=json

Thanks and Regards,

MD.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member690694
Participant
0 Likes

Thanks it's working fine now. I have added Accept manually then it's working fine.

former_member226
Employee
Employee
0 Likes

Hi,

For post-call, pls pass a header parameter "Content-Type" as "application/json"(https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type) and then the system will accept JSON input payload. Similarly, if you also want to get response back in JSON then also pass another header "Accept" as "application/json" (https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation/List_of_default_Accept_values).

BR
Saurabh

former_member690694
Participant
0 Likes

HI Saurabh,

I have passed content type - application/json but still on postman tool response in xml only and if try to change manually into json still it's in xml only on postman tool. Please find attached screen shot of it.

For get call i am getting after adding $format=json but this syntax in post method url is not working. COuld you please guide me again can we get in json for post method call.

Thanks and Regards,

MD.

former_member226
Employee
Employee
0 Likes

try adding "Accept" header with "application/json" as its value...This will return the response in JSON

former_member690694
Participant
0 Likes

Have you tried adding any value in Header Accept . Because i am not able to enter anything in Accept. Please find below screen shot of it.

Thanks and Regards,

MD.

former_member226
Employee
Employee
0 Likes

Can you pls attach the snapshot?

former_member690694
Participant
0 Likes

Please find attached screen shot of it. where i am not able to add for Accept.

former_member226
Employee
Employee

Pls see this: