cancel
Showing results for 
Search instead for 
Did you mean: 

Creating LeadCollection via ODATA in SAP C4C using POST call

former_member233212
Participant

Dear Experts,

I'm trying to post LeadCollection data from SAP CPI to SAP C4C using ODATA call. This works well when i do test connection in SAP C4C and when I post data from POSTMAN tool. However when I pass the same XML or JSON payload from CPI it does give me a parsing error. Please give me your inputs to fix this issue.

The URL is as below:

https://XXXX.com/sap/c4c/odata/v1/c4codataapi/LeadCollection

Also I get parsing error for both XML and JSON which one I should use?

When I use JSON payload:

Error Details
com.sap.gateway.core.ip.component.odata.exception.OsciException: Request Payload Parsing Failed for one of the reason: (1) Either the OData metadata content available in the server is outdated OR (2) The request payload seems to be incorrect. Error Details : only whitespace content allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1) , org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1) Request Payload : { "ObjectID": "1234", "AccountCountry": "SK", "AccountPartyID": "1000976", "Company": "RodičovskézdruženiepriMŠ2771",

When I use XML payload:

Error Details
com.sap.gateway.core.ip.component.odata.exception.OsciException: Request Payload Parsing Failed for one of the reason: (1) Either the OData metadata content available in the server is outdated OR (2) The request payload seems to be incorrect. Error Details : Entity Set entry not found in the edmx.
Request Payload :
<?xml version="1.0" encoding="utf-8"?>
<entry m:etag="W/"datetimeoffset'2019-05-24T13%3A02%3A44.8187640Z'"" xml:base="https://XXX/sap/c4c/odata/v1/c4codataapi/" xmlns="http://www.w3.org/2005/Atom" 

It would be helpful if you give some suggestions to move further on this.

Regards,

Vidhya Nizamkar

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor

Hi Vidhya

If you are using the OData adapter, your payload needs to be in XML format, and specifically adhering to the schema generated by the OData Query Wizard (that can be invoked from the Processing tab of the OData channel) for your POST operation. This replaces the OData Operations Modeler that was previously available via Eclipse.

The OData adapter automatically transforms the payload to Atom XML before calling the endpoint, so you cannot use the Atom XML (that you use directly from Postman) as the input to the adapter.

Regards

Eng Swee

former_member233212
Participant
0 Kudos

Thanks for explanation. I was able to fix the issue. 🙂

Answers (1)

Answers (1)

sumanth171
Active Participant
0 Kudos

Hello Vidhya,

The error shows there is a problem with your OData service metadata. If this created manually, can you please check if all the fields are in sync with the data posting to service. Also, try reloading metadata and test.

former_member233212
Participant
0 Kudos

Thanks Anil for you reply. The issue was with the data I was able to fix it.