I get an error stating "Cannot reference a foreign key field Parent_Case__r" whenever i am trying to use a relation field in the JSON request to REST API.
I have a lookup relation on one the child objects which i am trying to make use of in the following JSON request.
My Json structure is as follows :
{ "records" :[{ "attributes" : {"type" : "Case", "referenceId" : "ref1"}, "name" : "SampleCase", "Case_Type__c" : "Email2Case", "Child_Parent_Relationships__r" : { "records" : [{ "attributes" : {"type" : "myrelation__c", "referenceId" : "ref2"}, "Parent_Case__r": {"Case_Number__c" : "12354747"}, "External_Id__c": "52363565325632", "Sample__c": "Helloworld", "Status__c": "Active" }] } }] }
I am firing this request to the Composite Resource End-point for instance
/services/data/v35.0/composite/tree/Case/myrelation__c/12345
I have checked for some limitations such as the follows
- Up to five records of different types
- Up to a total of 200 records across all trees
- sObject trees upto 5 levels deep traversal
These criteria's doesn't seem to concern this scenario. Additionally i have checked other permissions related to the API and sObjects that could be causing this issue.
Kindly assist if i am missing something in this request. Or how do i use relationship in creating nested records during the REST call.
Any help will be appreciated. Thanks in advance !