0

I have two custom Objects:

  • CustomA
  • CustomB

CustomA has master-detail relationship with CustomB object. I would like to create record of both the objects in a single API call using composite API as defined here https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_composite_sobject_tree_create.htm but it's not working.

I am calling API services/data/v60.0/composite/tree/CustomA with the below payload

{
"records" :[{
    "attributes" : {"type" : "CustomA__c", "referenceId" : "ref1"},
    "Name" : "Testing",
    "CustomB__c" : {
      "records" : [{
         "attributes" : {"type" : "CustomB__c", "referenceId" : "ref2"},
         "name" : "Testing"
         }]
      }
  }]
}

and I am getting below error

[
    {
        "message": "Cannot deserialize instance of reference from START_OBJECT value { or request may be missing a required field at [line:4, column:20]",
        "errorCode": "JSON_PARSER_ERROR"
    }
]

I have validated the payload JSON and that's correct so it shouldn't be JSON_PARSER_ERROR.

It works if I remove the master-detail relationship so there is something wrong with defining the record of the CustomB object. I have also checked object permissions and that looks fine.

Can someone point out what's going wrong here?

7

0

You must log in to answer this question.

Browse other questions tagged .