Skip to Content
avatar image
Former Member

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

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • avatar image
    Former Member
    Jan 26, 2017 at 11:45 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Mar 01, 2017 at 04:17 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Apr 10, 2017 at 08:21 PM

    @Lars,

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

    Thanks,

    Tyler

    Add comment
    10|10000 characters needed characters exceeded