1

We have a Java application integrated to Salesforce that can create a case using the REST API like this:

POST /services/data/v33.0/sobjects/Case

Body:

{"Subject":"Test Subject","RecordTypeId":"012200000003230AAA","Account":{"MerchantAccountNumber__c":"MAN004370053"}}

Instead of using the account id to attach it to the right account, we use the external id field MerchantAccountNumber__c. This works fine.

Now this application needs to create a custom object MerchantProcess__c that is also related to Account over a master-detail relationship called AccountName__c, but we cannot get the REST call to work:

POST /services/data/v33.0/sobjects/MerchantProcess__c/

{"AccountName__c":{"MerchantAccountNumber__c":"MAN4290050938"},"RecordTypeId":"0128E000000Cuki","DetailedInformation__c":"Details here"}

This returns:

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

How could I create a MerchantProcess__c record over the REST api and attach it to an account while using the external id MerchantAccountNumber__c on Account?

It would be possible to query the account id by the MerchantAccountNumber__c and then create the MerchantProcess__c in a second call, but I want to avoid this if possible to save on api calls and reduce complexity.

2

You need to use __r and not __c

{"AccountName__r":{"MerchantAccountNumber__c":"MAN4290050938"},"RecordTypeId":"0128E000000Cuki","DetailedInformation__c":"Details here"}

And I am assuming that you are using upsert here as the DML method but you have not shown your code so...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.