0

I created a composite REST to insert opportunity for existing account, but all the GET method return error resource not found.. someone help

{
"allOrNone" : true,
"compositeRequest" : [{
    "method" : "GET",
    "referenceId" : "GetAccountId",
    "url" : "/services/data/v42.0/query/?q=select+id+from+contact+where+SAP_Account_Id__c=1213019"
},
{
    "method" : "GET",
    "referenceId" : "GetAccountDivisionId",
    "url" : "/services/data/v42.0/query/?q=select+id+from+Account_Division__r+where+SAP_External_Key__c='1213019'"
},
{
    "method" : "GET",
    "referenceId" : "GetSalesOfficeId",
    "url" : "/services/data/v42.0/query/?q=select+id+from+Sales_Office__r+where+SAP_External_Key__c='1213019'"
},
{
    "method":"POST",
    "url":"/services/data/v45.0/composite/tree/Opportunity",
    "referenceId":"CreateOpportunity",
    "body": {
        "attributes" : {"type" : "Opportunity", "referenceId" : "CreateOpportunity"},
        "name" : "Test",
        "AccountId" : "@{GetAccountId.records[0].Id",
        "Account_Division__r" : "@{GetAccountDivisionId.records[0].id}",
        "Plant__c" : "JKT",
        "Amount_Estimated__c" : "1000",
        "SAP_Inquiry_ID__c" : "INQ121319",
        "Sales_Office__r" : "@{GetSalesOfficeId.records[0].id}",
        "Inquiry_Amount_Original_Currency__c" : "1000",
        "Exchange_Rate__c" : "14000",
        "CloseDate" : "2019-12-30T18:25:43.511Z",
        "StageName" : "Preparation",
        "Data_Synced_to_SAP__c" : true,
        "LeadSource" : "Other"
    }
}]

}

1
  • Is it working if you use only the request /services/data/v42.0/query/?q=select+id+from+contact+where+SAP_Account_Id__c=1213019 in Workbench?
    – Badbaxx
    Nov 15, 2019 at 9:13

2 Answers 2

0

You cannot query from either Account_Division__r or Sales_Office__r. The __r notation is for relationships. These are the 'REST Resource(s) not found'

If they are relationships to Contact, you would need to query the SObject(s) and use the Id from Contact to limit the query further. You need to replace __r with __c to access the SObjects.

0

Another possible cause of a 404 in a composite REST is if you do the following:

where your URL that includes the above body is at a version earlier than the urls of the component requests. For example, if you used curl or Workbench and did:

/services/data/v41.0/composite

where the POST body was:

{
"allOrNone" : true,
"compositeRequest" : [{
    "method" : "GET",
    "referenceId" : "GetAccountId",
    "url" : "/services/data/v42.0/query/?q=select+id+from+contact+where+SAP_Account_Id__c=1213019"
}]

The /services/data/v42.0/query resource would not be found because the API is executing at version 41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .