The custom relationship name on a parent object, here Online_quotes1__r
, is used in SOQL to query from the parent down the child and in Apex to access queried child objects. You cannot, however, write to the custom relationship as a field in order to add new child objects.
Instead, you can manipulate the children directly. Here's an example with Contact and Account (where the relationship name is Contacts
, but the mechanism works the same way).
GET /services/data/v43.0/sobjects/Account/0013600001sxEUmAAM/Contacts
{ "totalSize" : 1, "done" : true, "records" : [ { "attributes" : { "type" : "Contact", "url" : "/services/data/v43.0/sobjects/Contact/0033600001qwBXEAA2" }, "Id" : "0033600001qwBXEAA2", "IsDeleted" : false, "MasterRecordId" : null, "AccountId" : "0013600001sxEUmAAM", "LastName" : "Testerson", "FirstName" : "Test", ... }
So that gets me a list of currently associated child objects, including their Ids. Suppose though that I have a Contact (this one, 0033600001qwBXEAA2
, that doesn't have a parent Account or that needs to be reparented. In that situation, I do
PATCH /services/data/v43.0/sobjects/Contact/0033600001qwBXEAA2
Body: { "AccountId": "YOUR_ACCOUNT_ID_HERE" }
Rather than touching the relationship name, I simply supply the lookup field on the child object.
Or, to create a new child, I do
POST /services/data/v43.0/sobjects/Contact/
Body: { "AccountId": "0013600001sxEUmAAM", "FirstName": "Tom", "LastName": "Test" }
And then I get back a response that includes the Id of the new child.