I am trying to insert 2 records at a time using canvas client in a connected app, using REST API, code and response below:
Sfdc.canvas.client.ajax('/services/data/v47.0/composite/sobjects',{
"allOrNone" : false,
client: Sfdc.canvas.oauth.client(), method: 'POST',
"records" : [{
"attributes" : {"type" : "Account"},
"Name" : "example.com",
"BillingCity" : "San Francisco"
}, {
"attributes" : {"type" : "Contact"},
"LastName" : "Johnson",
"FirstName" : "Erica"
}],
success: function(data){console.log(data.payload)}
})
Getting an error - "The HTTP entity body is required, but this request has no entity body."
But I am able to insert 1 record at a time with the code below.
Sfdc.canvas.client.ajax('/services/data/v47.0/sobjects/account/',{
client: Sfdc.canvas.oauth.client(),
method: 'POST', data: '{"Name" : "California"}',
success: function(data){console.log(data.payload)}
})
Any recommendation? Tried other implementations as described in
and