function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gtuerk_greensaasgtuerk_greensaas 

Using composite sObject Tree in Composite request

I'm able to create an Order using the resource /services/data/v43.0/composite/tree/order, passing into the body some standard Order fields and a custom object related record set.  So that works.
I'm able to create a composite request using the resource /services/data/v43.0/composite/ that generates a custom object, reads it back, generates another custom object.  These with simple posts with data including the fields to be filled on the object.  So that works.  
What I can't do is to chain a composite call to resource /services/data/v43.0/composite and includes one of the transactions as a Post to the tree resource.  Has anybody else solved this?  The tree resource has slight syntactical differences (records is the root, rather than just the first field on the object), and I've tried each way, but to no avail.  Here's a sample of my 

{
    "allOrNone" : true,
    "compositeRequest" : [{
        "method" : "POST",
        "url" : "/services/data/v43.0/sobjects/Service__c",
        "referenceId" : "NewService",
        "body" : {  
            "Name" : "Insert Product Name here",
            "Status__c" : "Ordered",
            "Technical_Contact__c" : "003Z000002wpIVVIA2",
            "Account__c" : "001Z000001MCkgLIAT"
        }
    },{
        "method" : "GET",
        "referenceId" : "NewServiceInfo",
        "url" : "/services/data/v43.0/sobjects/Service__c/@{NewService.id}"
    },{
        "method":"POST",
        "url":"/services/data/v43.0/composite/tree/Order",
        "referenceId":"NewOrder",
        "body": {
            "AccountId" : "001Z000001MCkgLIAT",
    "EffectiveDate" : "2018-08-01",
    "Status" : "Draft",
    "Ordered_Service_Components__r" : {
        "records":[{
            "attributes" : {"type":"Service_Component__c", "referenceId":"ref2"},
            "Monthly_Recurring_Revenue__c": 800,
            "Status__c":"Pending Install",
            "Service__c":"a08Z0000006Z52DIAS",
            "Product_Pricing_Item__c":"a05Z00000097NjzIAE"
        }]
    }
        }
    }]
}

Any suggestions or commentary from SFDC product are welcome
Raj VakatiRaj Vakati
try this
{
    "allOrNone" : true,
    "compositeRequest" : [{
        "method" : "POST",
        "url" : "/services/data/v43.0/sobjects/Service__c",
        "referenceId" : "NewService",
        "body" : {  
            "Name" : "Insert Product Name here",
            "Status__c" : "Ordered",
            "Technical_Contact__c" : "003Z000002wpIVVIA2",
            "Account__c" : "001Z000001MCkgLIAT"
        }
    },{
        "method" : "GET",
        "referenceId" : "NewServiceInfo",
        "url" : "/services/data/v43.0/sobjects/Service__c/@{NewService.id}"
    },{
        "method":"POST",
        "url":"/services/data/v43.0/composite/tree/Order",
        "referenceId":"NewOrder",
        "body": {
            "AccountId" : "001Z000001MCkgLIAT",
    "EffectiveDate" : "2018-08-01",
    "Status" : "Draft",
    "Ordered_Service_Components__r" : {
        "records":[{
            "attributes" : {"type":"Service_Component__c", "referenceId":"ref2"},
            "Monthly_Recurring_Revenue__c": 800,
            "Status__c":"Pending Install",
            "Service__c":@{NewService.id},
            "Product_Pricing_Item__c":"a05Z00000097NjzIAE"
        }]
    }
        }
    }]
}

 
gtuerk_greensaasgtuerk_greensaas
Raj - Thanks, but my problem isn't the bind variable syntax to pipe in the Service ID.  It is that it seems one cannot put a post to the tree resource within a composite request that chains together multiple calls.  The way around this would be to just decompose the tree into constituent object arrays but I would prefer to leverage the tree structure in addition to the chaining
Kalpesh Vyas 8Kalpesh Vyas 8
Hi @gtuerk_greensaas,
Did you get any solution of this yet?
Or we have to break only these calls?