To try out the steps in this section, install Postman and open the Postman collection we have prepared for you. In the collection, open the Create an invoice using existing Account and Product records request and replace variables with actual values.

Download Postman Open Postman Collection


Step 1: Create a POST request

Configure your application to send the following composite request:

POST https://{your_Salesforce_domain}/services/data/v44.0/composite

where


Step 2: Configure authorization

Make sure your request uses OAuth 2.0. Authorization data must be included in the request URL.


Step 3: Configure headers

Configure the request headers to include the following key-value pairs:

Key Value
Authorization Bearer {access_token}
Example:
Bearer 00D0N000000h6Yq!AR0AQObORnk9lCldrMydk1Y3cuyqpscqcU.T1xvoM1uWkWrr8MLu2ehJLKp7Mz3Qeu.eQGI13qlH_HfGEEMxV_J8FdI1TwdR
Content-Type application/json

Step 4: Add JSON payload

Add JSON payload to the request body. For example:

{
"allOrNone": true,
"compositeRequest":
    [
        {
        "method": "GET",
        "url": "/services/data/v44.0/sobjects/s2cor__Sage_INV_Trade_Document_Type__c/s2cor__UID__c/SalesInvoice_TD_US?fields=Id",
        "referenceId": "SalesInvoiceType"
        },
        {
        "method": "POST",
        "url": "/services/data/v44.0/sobjects/s2cor__Sage_INV_Trade_Document__c",
        "referenceId": "NewSalesInvoice",
        "body": {
        "s2cor__Account__c": "0011N00001FmNwLQAV",
        "s2cor__Trade_Document_Type__c": "@{SalesInvoiceType.Id}"
            }
        },
        {
        "method": "POST",
        "url": "/services/data/v44.0/sobjects/s2cor__Sage_INV_Trade_Document_Item__c",
        "referenceId": "NewLineItem",
        "body": {
        "s2cor__Product__c": "01t1N00000ErDKHQA3",
        "s2cor__Unit_Price__c": "1000.00",
        "s2cor__Trade_Document__c": "@{NewSalesInvoice.id}"
            }
        },
        {
        "method": "PATCH",
        "url": "/services/data/v44.0/sobjects/s2cor__Sage_INV_Trade_Document__c/@{NewSalesInvoice.id}",
        "referenceId": "PostedInv",
        "body": {
        "s2cor__Status__c": "Submitted"
            }
        }
    ]
}

In this JSON payload:


Step 5: Send your request

Send your request to create the invoice.