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 REST 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:

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, none of the parts are processed.

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: Retrieve Select Member Details, Retrieve Tier Details, and Create a Membership Card for a Member

This example request contains the following batch actions:

  • Part1- Retrieves the selected details of a member (party number, member number, member name) for a given the member number.
  • Part2 - Retrieves the tier details for the same member.
  • Part3 - Creates a membership card for the same member.
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": "/loyMembers/MEM0000002865?onlyData=true&fields=PartyNumber,MemberNumber,MemberName",
            "operation": "get"
	     },
	     {
            "id": "part2",
            "path": "/loyMembers/MEM0000002865/child/MemberTier/?onlyData=true",
            "operation": "get"
	      },
	      {
            "id": "part3",
            "path": "/loyMembers/MEM0000002865/child/cards",
            "operation": "create",
            "payload": {
            	    "ExpiryDate" : "2020-02-02T00:00:00-07:00",
				       "ExpiryDateOnCard" : "2020-02-02T00:00:00-07:00",
				       "NameOnCard" : "Vinay C",
			          "CardType": "Membership 1K"
       	 }
    }
	]
}

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

{
  "parts": [
    {
      "id": "part1",
      "path": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865",
      "operation": "get",
      "payload": {
        "PartyNumber": "CDRM_890466",
        "MemberNumber": "MEM0000002865",
        "MemberName": "Vinay C"
      }
    },
    {
      "id": "part2",
      "path": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/MemberTier",
      "operation": "get",
      "payload": {
        "items": [
          {
            "ActiveFlag": true,
            "Comments": "Default Member Tier",
            "ReasonValue": null,
            "CreatedBy": "LOYALTY_PROGRAM_ADMINISTRATOR",
            "EndDt": "2020-07-01T00:00:00+00:00",
            "LastUpdateDate": "2019-07-03T13:48:13.208+00:00",
            "MemberId": 300100177032480,
            "StartDt": "2019-07-03T13:48:13.662+00:00",
            "TierClassId": 300100176787580,
            "TierId": 300100176787581,
            "MemTierId": 300100177032482,
            "TierName": "Base",
            "LoyTierId": 300100176787581,
            "TierClassName": "Default tier class",
            "LoyTierClsId": 300100176787580,
            "LookupType": null,
            "LookupCode": null,
            "MemTierNum": "MT0000001786",
            "StartQualPdCode": "ORA_TR_MODEL_FIXED_DATE",
            "StartQualPd": "Fixed Date",
            "TillDate": "2019-07-01",
            "NextTierName": "Silver",
            "TierQualPoints": 5000,
            "QualPointsToUpgrade": 5000,
            "PresentQualPoints": 0
          }
        ],
        "count": 1,
        "hasMore": false,
        "limit": 25,
        "offset": 0,
        "links": [
          {
            "rel": "self",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/MemberTier",
            "name": "MemberTier",
            "kind": "collection"
          }
        ]
      }
    },
    {
      "id": "part3",
      "path": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards",
      "operation": "create",
      "payload": {
        "ActiveFlag": false,
        "CardNumber": "CARD0000003002",
        "CardTypeCode": "ORA_MEM_CARD_1K",
        "CardType": "Membership 1K",
        "CreatedBy": "LOYALTY_PROGRAM_ADMINISTRATOR",
        "CreationDate": "2019-07-11T05:36:40+00:00",
        "ExpiryDate": "2020-02-02T07:00:00+00:00",
        "ExpiryDateOnCard": "2020-02-02T07:00:00+00:00",
        "IssueDate": null,
        "LastUpdateDate": "2019-07-11T05:36:40.142+00:00",
        "LastUpdateLogin": "8C13AB0F2D7E090AE0530740F00A29DD",
        "LastUpdatedBy": "LOYALTY_PROGRAM_ADMINISTRATOR",
        "LoyCardId": 300100177435450,
        "NameOnCard": "Vinay C",
        "RequestDate": null,
        "StartDate": null,
        "StatusCode": null,
        "CardStatus": null,
        "MemberName": "Vinay C",
        "MemberNumber": "MEM0000002865",
        "TierName": "Base",
        "MemberTier": "Base",
        "MemberStatus": "Active",
        "ProgramName": "Vinay",
        "ExpiryStampedOnCard": "02/2020",
        "UpdateFlag": "true",
        "CA_DCL_Id_c": null,
        "CA_DCL_c": null,
        "CA_FOR_c": "100",
        "links": [
          {
            "rel": "self",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards/300100177435450",
            "name": "cards",
            "kind": "item",
            "properties": {
              "changeIndicator": "ACED0005737200136A6176612E7574696C2E41727261794C6973747881D21D99C7619D03000149000473697A65787000000001770400000001737200116A6176612E6C616E672E496E746567657212E2A0A4F781873802000149000576616C7565787200106A6176612E6C616E672E4E756D62657286AC951D0B94E08B02000078700000000178"
            }
          },
          {
            "rel": "canonical",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards/300100177435450",
            "name": "cards",
            "kind": "item"
          },
          {
            "rel": "parent",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865",
            "name": "loyMembers",
            "kind": "item"
          },
          {
            "rel": "lov",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards/300100177435450/lov/LOVVA_For_CA_DCL_c",
            "name": "LOVVA_For_CA_DCL_c",
            "kind": "collection"
          },
          {
            "rel": "lov",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards/300100177435450/lov/MemberPVO1",
            "name": "MemberPVO1",
            "kind": "collection"
          },
          {
            "rel": "lov",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards/300100177435450/lov/LookupPVOStatusCode",
            "name": "LookupPVOStatusCode",
            "kind": "collection"
          },
          {
            "rel": "lov",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards/300100177435450/lov/LookupPVOtype",
            "name": "LookupPVOtype",
            "kind": "collection"
          },
          {
            "rel": "lov",
            "href": "https://servername.fa.us2.oraclecloud.com/crmRestApi/resources/11.13.18.05/loyMembers/MEM0000002865/child/cards/300100177435450/lov/FK_LOVVA_For_CA_DCL_c",
            "name": "FK_LOVVA_For_CA_DCL_c",
            "kind": "collection"
          }
        ]
      }
    }
  ]
}

Example: Closing Multiple Purchase Order Lines

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"
}
	} 
}
]
}

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