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

Can you include multiple objects in a payload?

Hello - I have a webservice class that creates Accounts and Contacts. I am testing using Postman. When I include both Accounts and Contacts in a payload, I get the error message 'Only one operation within the same request is allowed.' 

Does this mean I can only include one object in a payload? 
          <tes:accountArray>                                     <tes:Name>Charles</tes:Name>                              <tes:BillingStreet>121 Test RD</tes:BillingStreet>   ​                                   <tes:BillingCity>PHOENIX</tes:BillingCity>​                                  <tes:BillingState>AZ</tes:BillingState>​                                <tes:BillingPostalCode>65906</tes:BillingPostalCode> 

                                           <tes:FirstName>Ray</tes:FirstName>                               <tes:LastName>Charles</tes:LastName>                                       <tes:MailingStreet>121 Test RD</tes:MailingStreet>                                        <tes:MailingCity>PHOENIX</tes:MailingCity>                                 <tes:MailingState>AZ</tes:MailingState>                                 <tes:MailingPostalCode>60906</tes:MailingPostalCode> 

SwethaSwetha (Salesforce Developers) 
HI Dbjensen,
You might want to try the approach suggested in according to which,

The "composite" resource allows you to both:
Execute multiple subrequests as part of a single top-level request
Reference data from previous requests in a subsequent subrequests

The url you'd use to make a composite request is https://<your instance here><api version>/composite/

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
AnudeepAnudeep (Salesforce Developers) 
Yes it possible

Here is an example from the documentation
<soapenv:Envelope xmlns:soapenv="" xmlns:urn="" xmlns:urn1="" xmlns:xsi="">
      <urn:sessionId>[sessionId retrieved from the login() call]</urn:sessionId>
      <urn:sObjects xsi:type="urn1:Account">
        <Name>Sample Account Two</Name>
        <!-- Siebel_Id__c is the External Id field present on Account object -->
      <urn:sObjects xsi:type="urn1:Contact">

Also, a similar question is discussed here

Let me know if it helps
Thanks for this helpful info. One more question. If my DML insert for the contact and account are in separate methods, within the same class, can I include both methods in the body? (So I'm sending 1 payload with 2 methods?)