Skip to Content
1

C4C - How to Create a Lead or Opportunity with OData? Syntax error in body

Jan 19, 2017 at 02:29 PM

326

avatar image

Hello,
i want to create a Lead or Opportunity with OData over HTTP with an external tool.

1. I check the Opportunity Collection with the GET-Method and Basic Auth
URL: https://xxxxxxxx.crm.ondemand.com/sap/c4c/odata/v1/c4codata/OpportunityCollection?$format=json

2. I fetch a token with the GET-Method and Basic Auth
URL: https://xxxxxxxx.crm.ondemand.com/sap/c4c/odata/v1/c4codata/

3. I try to create an Opportunity with POST-Method, x-csrf-token and Basic Auth
URL: https://xxxxxxxx.crm.ondemand.com/sap/c4c/odata/v1/c4codata/OpportunityCollection

Body: ???

Does someone has a minimal code example?
Evertime i try to create an Opportunity, i get an error. Same with Lead.

Thanks and best regards
Lars

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Lars Pülm Jan 26, 2017 at 11:45 AM
0

Hello again,
now i can create a ServiceTicket with OData in C4C.

In the next steps i want to create a lead. In an older question (https://archive.sap.com/discussions/message/16421946#16421946), i figured out that i have to use the "pcmportal" (URL: https://xxxxxxxx.crm.ondemand.com/sap/c4c/odata/v1/pcmportal/LeadCollection). It looks like an invisible odata service, because i don't see it in the admin area but can request the leadCollection.

My problem is, if i try to create the lead i get errors with this example (the mandatory field are "accountname of the customer", "name of the lead" and "ContactLastName"):

{  "Accountname": "Test",  "Name": "Testlead",  "ContactLastName": "Marketing Lead Person Last Name"}
<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">  <code>00145E5B1CC71EE0AB8B3A3B086F432E</code>  <message xml:lang="de">Der Data-Services-Request wird wegen inkorrekter Syntax nicht verstanden</message></error>

Any idea?

Thanks and best regards
Lars

Share
10 |10000 characters needed characters left characters exceeded
Daniel Gegenheimer Mar 01, 2017 at 04:17 PM
0

Hi there,

I've the same issue doing a GET on the address: https://myXXXXXX.crm.ondemand.com/sap/c4c/odata/v1/pcmportal/DealRegistrationCollection/$count

getting this result:

<?xml version="1.0" encoding="utf-8"?>
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
    <code>00145E5B1CC71ED0B4E35610A1174A95</code>
    <message xml:lang="en">The Data Services Request has been understood, but it is refused. User is succesfully authenticated. The request SHOULD NOT be repeated.</message>
</error>

Any Ideas?


Best Regards,

Daniel

Share
10 |10000 characters needed characters left characters exceeded
Atul Barve Apr 10, 2017 at 08:21 PM
0

@Lars,

I'm having the same issue as well. Were you able to resolve this?

Thanks,

Tyler

Share
10 |10000 characters needed characters left characters exceeded