+ Start a Discussion
KJesseKJesse 

Rest API cURL request for Hierarchy SObject

Hi I am trying to send a cURL update to a salesforce object. I have had no problem with other fields like checkbox and picklist but I cannot figure out a hierarchy sobject. The field I am trying to update via cURL is 

Name: Parent Account                         API: Parent                                            Type: Hierarchy

What my content looks like is below with the following error. What do I need to do to send a valid cURL command to update this field?

Content
$content = json_encode ( array (
			"Name" => $fields ['Client_Name'],
			"Parent" => 'Some Nested SObject'
	) );

The error is:
[{"message":"The value provided for foreign key reference Parent is not a nested SObject","errorCode":"INVALID_FIELD"}]

Thanks for any help :)
 
Best Answer chosen by KJesse
KJesseKJesse
Fixed this. I just needed to append ID to the lookup field. 
 
$content = json_encode ( array (
			"Name" => "Some name",
			"ParentId" => '0011y00000749BHG' 
			));

 

All Answers

Vamsi KrishnaVamsi Krishna
can you try setting the value for parent field as a salesforce account id and see if it works
KJesseKJesse
I tried that with no such luck. I also tried many of these paths https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_list.htm and also the instance url path for a typical curl command. Any other ideas?
KJesseKJesse
Fixed this. I just needed to append ID to the lookup field. 
 
$content = json_encode ( array (
			"Name" => "Some name",
			"ParentId" => '0011y00000749BHG' 
			));

 
This was selected as the best answer