function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

How to refer external id in REST API composite/tree

Hi All,

I have a required where i need to create Account with Contact and attachment under the contact.
I also need to refer a look up value(Test_Rec_Type_Object__c) on Account with the help of external id and the same with contact as well. On contact i have a look up(Test_Object__c) which i need to refer with the external id.

Here is the snippet which i used from workbench REST API...

"records" :[{
    "attributes" : {"type" : "Account", "referenceId" : "ref1"},
    "name" : "Acc with Con with Att New",
    "phone" : "1234567890",
    "website" : "",
    "numberOfEmployees" : "100",
    "industry" : "Banking",
    "Test_Rec_Type_Object__c" : {
       "Text_External_Unique__c" : "12345" },

    "Contacts" : {
      "records" : [{
         "attributes" : {"type" : "Contact", "referenceId" : "ref2"},
         "lastname" : "Smith",
         "Title" : "President",
         "email" : "",
         "Test_Object__c" : {
            "TO_External_Obj__c.Id" : "67890" },

    "Attachments" : {
      "records" : [{
         "attributes" : {"type" : "Attachment", "referenceId" : "ref3"},
         "Name": "TestPDF.pdf", 
         "body": "Attach with Rec Creation"

Here is the error i am getting... Could any one please help on this... There is some problem in referencing the external id(Highlighted bold)

Cannot deserialize instance of reference from START_OBJECT value { or request may be missing a required field at [line:8, column:27]
This link might help next watchers:
robert crouserobert crouse
To refer to an external id in a REST API composite or tree, you must first find the component's id. You can do this by calling [getComponentId](https://[your api url]?method=composite/tree&action=getComponentId) on the component that contains the external id.
burak sağmanburak sağman
İzmir SEO Hizmetleri ( ile en iyi SEO hizmetleri almanın yanında siteniz ihtiyacı olan bir çok konuda teknik destek alabilirsiniz.