Create Salesforce Case object with nested relationships using REST API
api, rest, salesforce
Solution
Figured it out by simply setting the AccountId and ContactId attributes on the new Case object.
Problem
I am attempting to create a new Case object using the REST API but need to find out how to format the JSON body to pass in nested SObjects. It's not apparent in the Docs, and I can't seem to find any examples. Anyone have any pointers or have done this before? The SF web UI uses a text lookup field to set the (related) Contact and Account, and I need to figure out how to either bypass the need for a lookup or embed the SObjects of the related records in the JSON. ``` [{"message":"The value provided for foreign key reference Contact is not a nested SObject","errorCode":"INVALID_FIELD"}] ```