• Hari M 22
  • NEWBIE
  • 5 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hello everyone,

The SalesForce REST API doc is unclear about the usage of APIs to insert and update records in OpportunityLineItem. The standard fields in OLI include OpportunityId and Product2Id both of which I'm populating by retrieving the appropriate SalesForce IDs. I receive this error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY when I try to insert a record at this URI: /sobjects/OpportunityLineItem/.

Going through the flow: https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_erd_products.htm#topic-title, I'm assuming this (and also the cross-reference error) means that there is no direct relationship between OLI and Products.

Firstly, why is there a Product2Id field if the relationship doesn't exist?
Secondly, is the URI I'm using incorrect? If so, what is the correct one?
Thirdly, can this problem be solved using APIs at all?

Maybe I'm going about this in a completely inefficient manner. Any suggestions would be greatly appreciated.
Hi ,

I am developing a custom integration application for creating sales orders in Salesforce. I am using xml for sending data in salesforce while calling the API. But I was unable to create the sales order in Sales force. The same data when I am sending using JSON is woking but with XNL it is not woking. I have converted the same JSON data to XML using the online tools but it is not working. 

My JSON eequest data is like this 

URL: https://ap2.salesforce.com/services/data/v30.0/commerce/sale/order 
 
 
HEADERS 
    Authorization: Bearer XXXXXXXXXXXXPANkBmIlOTVrgLcSJxArivqsXXX
    Content-Type : application/json 
 
 
REQUEST BODY 


   "order": [ 
   { 
      "attributes": { 
      "type": "Order" 
      }, 
      "EffectiveDate": "2015-04-11", 
      "Status": "Draft", 
      "billingCity": "SFO-Inside-OrderEntity-1", 
      "accountId": "00128000002l6q5AAA", 
      "Pricebook2Id": "01s28000000uD8IAAU", 
      "OrderItems": { 
         "records": [ 
            { 
            "attributes": { 
               "type": "OrderItem" 
            }, 
            "PricebookEntryId": "01u28000000eeirAAA", 
            "quantity": "1", 
            "UnitPrice": "15.99" 
            } 
         ] 
      } 
   } 
   ] 


and the XML request date is like this

REQUEST BODY


<order>
    <attributes>
        <type>order</type>
    </attributes>
    <EffectiveDate>2015-04-11</EffectiveDate>
    <Status>Draft</Status>
    <billingCity>SFO-Inside-OrderEntity-1</billingCity>
    <accountId>00128000002l6q5AAA</accountId>
    <Pricebook2Id>01s28000000uD8IAAU</Pricebook2Id>
    <OrderItems>
        <records>
            <attributes>
                <type>OrderItem</type>
            </attributes>
            <PricebookEntryId>01u28000000eeirAAA</PricebookEntryId>
            <quantity>1</quantity>
            <UnitPrice>15.99</UnitPrice>
        </records>
    </OrderItems>
</order>

But the xml is not working it is giving error 

An unexpected error occurred. Please include this ErrorId if you contact support: 697865704-94096 (-871941818)

Please suggest some wayout.

Thanks in advance