Perform Batch Actions

You can combine multiple operations into a single HTTP request (batch actions) to improve performance. The request body is a JSON object with a field named parts, which is an array of objects. Each object in the array contains:
  • A unique ID
  • A relative path to the resource
  • An operation
  • (Optional) A payload
You can also use batch requests to perform custom actions. However, all custom actions may not be supported in batch requests. For the unsupported custom actions, the batch request displays this error: The action {ACTION_NAME} isn't enabled for batch execution.

Note:

There is no limitation on concurrent requests and batch size imposed by the framework. Individual parts in a batch request are executed sequentially. However, there might be limit/constraints in the operational environment. For example:- REST Service owner might have configured a request timeout for the service. Also, there might be a generic request timeout configured on the server. If REST object is heavy, then there will be some performance issues on bulk data processing via batch.

When performing an UPSERT operation, you must consider these:

  • If you do not require a response, then you can suppress the response by using the following headers:
    
    Accept: application/vnd.oracle.adf.resourceitem+json;q=0
    Accept-Encoding: identity

    This does not display the response and prevents Formula Fields being reevaluated at the parent-level.

  • When updating or inserting a child record, you must include the complete path of the child record in the path parameter. For example, you must use "path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555" and not "path": "/opportunities/".

Note:

If a single part in the payload for a batch request fails, then all the other parts also implicitly fail because batch actions are essentially all-or-none actions. If a certain part fails due to an error, then only the part containing the error is listed in the response. Parts without errors aren't listed in the response. However, non of the parts are processed. The server returns a 204 status and it is expected during this operation.

The JSON schema of a batch action request is as follows:


{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "title": "Batch execution",
    "description": "Group multiple requests together ('part').",
    "definitions": {
        "Part": {
            "type": "object",
            "allOf": [
                {
                    "properties": {
                        "id": {
                            "type": "string",
                            "description": "An identification provided by the client to distinguish each part provided in the batch request."
                        },
                        "path": {
                            "type": "string",
                            "description": "Resource's location."
                        },
                        "operation": {
                            "type": "string",
                            "enum": [
                                "get",
                                "create",
                                "update",
                                "replace",
                                "delete"
                            ],
                            "description": "The operation that will be performed."
                        },
                        "preconditionSucceeded": {
                            "type": "boolean",
                            "description": "This attribute is set in the batch response only when ifMatch or ifNoneMatch are provided in the request. It will be 'true' if the precondition (ifMatch/ifNoneMatch) was satisfied, otherwise 'false'."
                        },
                        "payload": {
                            "oneOf": [
                                {
                                    "$ref": "resource-item.json",
                                    "description": "The payload that will be used in the operation. Example: a resource instance should be provided in order to execute a 'create'."
                                },
                                {
                                    "type": "null"
                                }
                            ]
                        }
                    },
                    "required": [
                        "id",
                        "path",
                        "operation"
                    ]
                }
            ],
            "anyOf": [
                {
                    "properties": {
                        "ifMatch": {
                            "type": "string",
                            "description": "This attribute is analogous to the If-Match header. It represents a precondition to execute this operation. The value can be null (same effect of 'If-Match: *') or an array of resource versions."
                        }
                    }
                },
                {
                    "properties": {
                        "ifNoneMatch": {
                            "type": "string",
                            "description": "This attribute is analogous to the If-None-Match header. It represents a precondition to execute this operation. The value can be null (same effect of 'If-None-Match: *') or an array of resource versions."
                        }
                    }
                }
            ],
            "description": "Represents a request."
        }
    },
    "properties": {
        "parts": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/Part"
            },
            "description": "Array that represents multiple requests."
        }
    },
    "required": [
        "parts"
    ]
}

Example: Retrieving an Existing Opportunity, Creating a New Opportunity, and Retrieving an Opportunity Contact

This request retrieves an existing account, creates a new account, and retrieves a sales team member details:

Note:

When updating or inserting a child record, you must include to the complete path of the child record in the path parameter. For example, you must use "path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555" and not "path": "/opportunities/".
curl \
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/ \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{
"parts": [
{
	"id": "part1",
	"path": "/opportunities/CDRM_93472",
	"operation": "get"
},
{
	"id": "part2",
	"path": "/opportunities",
	"operation": "create",
	"payload": {
	"Name" : "Major Application Upgrade"
}
}
{
"id": "part3",
"path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555",
"operation": "get"
}
]
}

The response body contains the result and uses the same media type as the request.


{
"parts": [
{
"id": "part1",
"path": "/opportunities/CDRM_93472",
"operation": "get"
"payload" : {
"BudgetAvailableDate": null,
"BudgetedFlag": false,
"PrimaryOrganizationId": 204,
"ChampionFlag": false,
"CreatedBy": "SALES_ADMIN",
"CreationDate": "2018-01-08T12:00:24.972+00:00",
"CurrencyCode": "USD",
"SalesMethodId": 300100073102472,
"SalesStageId": 300100073102473,
"CustomerAccountId": null,
"DealHorizonCode": null,
"DecisionLevelCode": null,
"Description": null,
"LastUpdateDate": "2018-01-08T12:24:05.310+00:00",
"LastUpdatedBy": "SALES_ADMIN",
"LastUpdateLogin": "6242B5ED93BE3EC9E0539EBDF20ABB8B",
"Name": "Big Data Analytics Servers",
"OptyId": 300100125332293,
"OptyNumber": "CDRM_93472",
},
},
{
"id": "part2",
"path": "/opportunities",
"operation": "create",
"payload" : {
BudgetAvailableDate: null
BudgetedFlag: false
PrimaryOrganizationId: 204
ChampionFlag: false
CreatedBy: "SALES_ADMIN"
CreationDate: "2015-06-04T03:08:27-07:00"
CurrencyCode: "USD"
SalesMethodId: 100000012430001
SalesStageId: 100000012430007
Name: "Major Application Upgrade"
OptyId: 300100111705686
OptyNumber: "CDRM_332708"
}
{
"id": "part3",
"path": "/opportunities/CDRM_3341580/child/OpportunityContact/300100092629555",
"operation": "get"
"payload" : {
AffinityLvlCd: null,
Comments: null,
ContactedFlg: "N",
PartyName: "Juan BELL",
OptyConId: 300100092629555,
PERPartyId: 100000018544431,
CreatorPartyId: 100010025532672,
CreatedBy: "MHoope",
CreationDate: "2016-11-16T05:15:38-08:00",
LastUpdateDate: "2016-11-16T05:15:43-08:00",
ContactPointId: 100000018544441,
FormattedAddress: "1625 19th Ave,SEATTLE, WA 98122",
FormattedPhoneNumber: "2065584951",
ContactPartyNumber: "100000018544430",
...
}
}
]
}

Example: Retrieving an Existing Sales Territory and Updating Another Sales Territory

This request retrieves an existing sales territory and updates the details of another sales territory:

curl \
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/ \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{
"parts": [
{
"id": "part1",
"path": "/territories/100000015312131",
"operation": "get"
},
{
"id": "part2",
"path": "/territories/300100128873880",
"operation": "update",
"payload": {
	"Name":"Rest_Terr_Updated",
	"Description" : "Updating a Draft Territory"
	}
}
]
}

The response body contains the result and uses the same media type as the request.


{
"parts":[
{
"id":"part1",
"path":"/territories/100000015312131",
"operation":"get",
"payload" :{
	"EffectiveEndDate": "4713-01-31"
	"EffectiveStartDate": "2010-01-13"
	"Name": "APAC Sales QA Organization Type"
	"TerritoryVersionId": 100000015312131
	"OwnerResourceId": 100010032635399
	...
	}
}, 
{
"id" : "part2",
"path" : "/territories/300100128873880",
"operation" : "update",
"payload" : {
	"Description": "Updating a Draft Territory",
	"EffectiveEndDate": null,
	"EffectiveStartDate": null,
	"Name": "Rest_Terr_Updated",
	"TerritoryVersionId": 300100091635502,
	"OwnerResourceId": 100010025532672,
	...
	} 
}
]
}

Example: Closing Multiple Purchase Order Line

This request closes multiple purchase order lines in a batch:

curl \
http://servername:fa.us2.oraclecloud.com/fscmRestApi/resources/11.13.18.05/ \
-H Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=??? \
-H Content-Type: application/vnd.oracle.adf.batch+json???
{
"parts":[
{
"id" : "part1",
"path" : "purchaseOrders/100000019476400/child/lines/702260/action/close",
"operation" : "invoke",
"payload" :{
{
	"closeAction" : "closeForReceiving"
},
{
	"closeReason" : "Close for receiving reason line 1"
}
	}
}, 
{
"id" : "part2",
"path" : "purchaseOrders/100000019476400/child/lines/702261/action/close",
"operation" : "invoke",
"payload" :{
 {
	"closeAction" : "closeForReceiving"
},
{
	"closeReason" : "Close for receiving reason line 2"
}
	} 
}
]
}

Example: Create Multiple Products for Multiple Subscriptions

This request lets you create multiple products for multiple subscriptions in a batch:
https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05 \
-H 'Method: POST' \
-H 'Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=' \
-H 'Content-Type: application/vnd.oracle.adf.batch+json'
{ "parts": [
        {
            "id": "part1-21002",
            "path": "/subscriptions/21002/child/products",
            "operation": "create",
            "payload": {
                "ProductName":"KiDT256GB_W",
                 "LineNumber":3
            }
        },
           {
            "id": "part2-21002",
            "path": "/subscriptions/21002/child/products",
            "operation": "create",
            "payload": {
                "ProductName":"SUBSCRIPTION ITEM",
                 "LineNumber":4
            }
        }
   ]
}
The response body contains the result and uses the same media type as the request.
{
    "parts": [
        {
            "id": "part1-21002",
            "path": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/subscriptions/21002/child/products",
            "operation": "create",
            "payload": {
                "SubscriptionProductId": 300000264330468,
                "SubscriptionId": 300000056319703,
                "LineNumber": "3",
                "SubscriptionProductPuid": "21002-PRDT-154068",
                "DefinitionOrganizationId": 300000001621747,
                "SubscriptionNumber": "21002",
                "SalesProductType": "COVERAGE",
                "Description": "Extended warranty for Kingston DT 256GB",
                "InventoryItemId": 300000002191542,
                "ItemUnitOfMeasure": "YR",
                "ProductName": "KiDT256GB_W",
                "Quantity": 1,
                "StartDate": "2019-08-23",
                "EndDate": null,
                "CloseReason": null,
                "CloseCreditMethod": null,
                "CancelReason": null,
                "ClosedDate": null,
                "CanceledDate": null,
                "RenewedDate": null,
                "PriceListId": null,
                "UnitPrice": null,
                "Status": "ORA_DRAFT",
                "Currency": "USD",
                "InvoicingRuleId": -2,
                "InvoicingRuleName": "Advance Invoice",
                "BillOnDay": null,
                "BillingOffsetDays": null,
                "BillingFrequency": "YR",
                "BillingFrequencyName": "Year",
                "AccountingRuleId": -104,
                "AccountingRuleName": "12 Months Fixed",
                "TransactionTypeName": "Invoice",
                "InvoiceText": "[$Product Name]: [$Charge Name] [$Bill from Date]-[$Bill to Date]",
                "BillToPartyId": 300000004212903,
                "BillToPartyNumber": "22610",
                "BillToAccountId": 300000004212905,
                "BillToAccountNumber": "21022",
                "BillToAccountDescription": "BA_CUST_STATEMENT",
                "BillToSiteUseId": 300000004212910,
                "BillToAddress": "Main Street,NEW YORKNY10001NEW YORK,US",
                "ShipToPartyId": null,
                "ShipToPartyName": null,
                "ShipToPartySiteId": null,
                "ShipToPartySiteName": null,
                "PaymentMethod": null,
                "PaymentMethodName": null,
                "PONumber": null,
                "WireNumber": null,
                "PaymentTermsId": 4,
                "PaymentTermsName": "30 Net",
                "PrePaymentNumber": null,
                "TaxExemptionHandling": "S",
                "TaxExemptionHandlingName": "Standard",
                "ExemptCertificateNumber": null,
                "ExemptReason": null,
                "OutputTaxClassification": null,
                "ProductFiscClassification": null,
                "TaxError": null,
                "CoverageScheduleId": null,
                "RenewalType": "RENEW",
                "BillingDateCode": "ORA_PERIOD_START",
                "BillingDateName": "Period start",
                "TotalContractValue": null,
                "EstimatedTax": null,
                "PricingError": null,
                "PriceAsOf": "2022-09-27",
                "PriceTransactionOn": "2022-09-27",
                "InvoicedAmount": null,
                "CreditedAmount": null,
                "CanceledAmount": null,
                "ClosedAmount": null,
                "SourceSystem": null,
                "SourceKey": null,
                "SourceNumber": null,
                "SourceLineKey": null,
                "SourceLineNumber": null,
                "MonthlyRecurringRevenue": null,
                "Duration": null,
                "Period": null,
                "GenerateBillingSchedule": null,
                "ExternalAssetKey": null,
                "ExternalParentAssetKey": null,
                "ExternalPriceListId": null,
                "ExternalRootAssetKey": null,
                "PriceListName": null,
                "NextPricingDate": null,
                "PricingTermsStartDate": null,
                "PricingTermsPricingMethod": null,
                "PricingTermsPeriod": null,
                "PricingTermsDuration": null,
                "PricingTermsAdjustmentPCT": null,
                "CorpCurrencyCode": "USD",
                "CurcyConvRateType": "Corporate",
                "AmendCreditMethod": null,
                "AmendCreditMethodName": null,
                "AmendDescription": null,
                "AmendEffectiveDate": null,
                "AmendReason": null,
                "AmendReasonName": null,
                "StatusMeaning": "Draft",
                "EnablePricingTermsFlag": null,
                "NextBillStartDate": null,
                "TaxClassificationMeaning": null,
                "CreatedBy": "alexandra.rabaea",
                "CreationDate": "2022-09-27T08:28:09+00:00",
                "LastUpdatedBy": "alexandra.rabaea",
                "LastUpdateDate": "2022-09-27T08:28:13.006+00:00",
                "LastUpdateLogin": "E2CE626179F963F0E0538AED3C0A1A5F",
                "SummarizedBillingFlag": null,
                "InterfaceOffsetDays": null,
                "CoverageName": null,
                "SuspendReason": null,
                "SuspendedDate": null,
                "SuspendCreditMethod": null,
                "ResumeDate": null,
                "ResumeDuration": null,
                "ResumePeriod": null,
                "AutoExtendFlag": null,
                "ChurnProbability": null,
                "EarlyTerminationPenalty": null,
                "EarlyTerminationFee": null,
                "GracePeriod": null,
                "PenaltyValue": null,
                "PenaltyChargeName": "Penalty Fee",
                "EarlyTerminationPenaltyName": null,
                "ChurnPredictionTrend": null,
                "PriceAdjustmentType": null,
                "PriceAdjustmentBasis": null,
                "PriceAdjustmentPercent": null,
                "DisplaySequence": null,
                "RelatedInventoryItemId": null,
                "RelatedProductName": null,
                "ProductChangeReason": null,
                "ProductChangeSchedule": null,
                "ProductChangeScheduleFrom": null,
                "DropOneTimeChargeFlag": null,
                "RelatedProductDescription": null,
                "GenerateBillFullPeriodFlag": null,
                "RenewalPaymentMethod": null,
                "RenewalPoNumber": null,
                "RenewalWireNumber": null,
                "RenewalPaymentMethodName": null,
                "CustomerTrxTypeSequenceId": null,
                "RepriceFlag": null,
                "AlignBillingFrom": null,
                "PendingActivationFlag": null,
                "RatePlanDocumentId": null,
                "RatePlanId": null,
                "RatePlanNumber": null,
                "RatePlanName": null,
                "BillToSiteNumber": null,
                "ShipToPartyNumber": null,
                "ShipToPartySiteNumber": null,
                "SalesOrderId": null,
                "SalesOrderNumber": null,
                "OrderFulfillLineId": null,
                "OrderFulfillLineNumber": null,
                "EnableUpfrontBillingFlag": null,
                "BillToContactId": null,
                "ShipToAccountId": null,
                "ShipToContactId": null,
                "WarehouseId": null,
                "BillToPartyName": "BA_CUST_STATEMENT",
                "BillToContactName": null,
                "ShipToAccountNumber": null,
                "ShipToContactName": null,
                "WareHouseName": null,
                "ShipToAccountDescription": null,
                "BillToContactNumber": null,
                "ShipToContactNumber": null,
                "ShipToContactPartyId": null,
                "UsageInvoiceLayoutTemplate": null,
                "EnableProrateByDay": null,
                "RequestedRatePlanId": null,
                "RequestedRatePlanNumber": null,
                "RenewalDuration": null,
                "RenewalDurationPeriod": null,
                "RenewalDurationPeriodName": null,
                "DefaultRevenueAction": null,
                "OverrideCreditAmount": null,
                "CalculatedCreditAmount": null,
                "TrackingId_c": null,
                "links": [
...
}

Batch processes help you get tasks done more quickly and efficiently.