2

I'm upserting a custom object via the REST api. How can I use the REST api to populate the record owner using an external id? See details below:

Endpoint:

/services/data/v42.0/sobjects/finserv__Alert__c/FinServ__SourceSystemId__c/test-external_id

Method: PATCH

Body:

{  
    "FinServ__Account__r":{  
        "External_Id__c":"account-external-id-1"
    },
    "FinServ__Message__c":"Alert-Subject-Finserv-CREATE-1",
    "FinServ__MessageDescription__c":"Alert-Description-Finserv-CREATE-1",
    "FinServ__Active__c":false,
    "Owner":{  
        "External_Id__c":"user-external-id-1"
    }
}

I get the following error when I run this in workbench:

message: Unexpected character ('F' (code 70)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [line:1, column:2]
errorCode: JSON_PARSER_ERROR

This seems to be because Owner is a UserOrGroup lookup, and not a lookup to a single object. The moment I remove "Owner": {...} from the payload, it succeeds.

How can I use the REST api to populate the record owner using an external id?

  • when you put in a valid SF user id into that field what happens? Also, can you post the request class that you are deserializing your json to? – PartOfTheOhana May 14 at 23:18
  • 4
    You're going to have to write a custom endpoint if you want to support that behavior, or add a separate field to hold the external id, then populate OwnerId via trigger. – Adrian Larson May 15 at 0:57
0

I used a Custom REST API and populated OwnerId via the apex logic of the Custom REST API

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.