I am creating a custom REST API that receives as input the following structure:

  1. Subscription record (main record)
  2. Order Product record (Parent of Subscription)

I want to update the Subscription record and also the Order Product record. However, i cannot access the "csord__Order_Product__r" information of the given request.

Sample Request:

"inputSub": {
    "name": "My Test Subscription record",
    "Id": "a0c1l000002KATkAAO",
    "csord__Order_Product__r": {
        "Id": "a0T1l000005ACEDEA4",
        "name": "Test Order Product",
        "el_Status_Reason__c": "Cancellation"

APEX Code:

@HttpPut global static getSubscriptionInformation doPost(csord__Subscription__c inputSub){
    system.debug('input is: ' +inputSub);
    getSubscriptionInformation result = new getSubscriptionInformation();
    try {
        update inputSub; //update Subscription record
        update inputSub.csord__Order_Product__r; //update related Order Product record
        result.orderProductResult.Subscription = inputSub;
        return result;
    } catch (Exception e) {
        system.debug('Exception: ' +e.getMessage());
        result.error_code = '1';
        result.error_message = e.getMessage();
    return result;
  1. Can i somehow access the "parent" element from the given request and update it?
  2. Should i change the structure in order to always get the parent record and then the child?

1 Answer 1


you are storing JSON request in csord__Subscription__c which is not correct as you are dealing with 2 objects.

you need to take JSON request as string and parse data using JSON.deserialize().

please refer to salesforce docs

to parse JSON either you can use Map<String,Object> which is provided as example in docs. or you can use a wrapper class to match JSON format.

Not the answer you're looking for? Browse other questions tagged .