I am using Salesforce's REST API to (1) retrieve a list of object IDs according to a query, then (2) retrieve the records that correlate to those IDs. I am familiar with the Salesforce composite documentation here.
My request looks like this:
POST: /services/data/v48.0/composite
{
"allOrNone":false,
"compositeRequest": [ {
"method":"GET",
"url": "/services/data/v48.0/query?q=SELECT+Id+FROM+My_Entity+WHERE+(CreatedById+!=+'asdfghjkl')",
"referenceId": "myEntity"
},{
"method":"GET",
"url": "/services/data/v48.0/composite/sobjects/My_Entity?ids=@{myEntity.records[0].Id}",
"referenceId":"myObject"
}]
}
My response:
{
"compositeResponse" : [ {
"body" : {
"totalSize" : 21,
"done" : true,
"records" : [ {
"attributes" : {
"type" : "My_Entity",
"url" : "/services/data/v48.0/sobjects/My_Entity/a0D6g000xxxxxxx"
},
"Id" : "a0D6g000xxxxxxx"
}, {*record2*}, {*etc*}
]},
"httpHeaders" : { },
"httpStatusCode" : 200,
"referenceId" : "myEntity"
}, {
"body" : [ {
"errorCode" : "PROCESSING_HALTED",
"message" : "'myEntity.records' references an invalid Datatype. Only Strings and primitive data types are allowed to be referenced from previous operations."
} ],
"httpHeaders" : { },
"httpStatusCode" : 400,
"referenceId" : "myObject"
} ]
}
The first subrequest (the query) executes without errors. My problem is the second subrequest. I understand from Salesforce documentation that I can refer to the ID of a single item (e.g. myEntity.records[0].Id
). Question: How do I use all items from myEntity.records
in the second subrequest?