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:

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: Retrieving a Procurement Agent and Creating a Procurement Agent

This request retrieves a procurement agent and creates a procurement agent:

curl \
https://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": "/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation": "get"
},
{
"id": "part2",
"path": "/procurementAgents",
"operation": "create",
"payload": {
	"Address" : [ 
		{
     "AgentId": 300100008259523,
     "ProcurementBUId": 1016,
     "Status": "Active",
     "DefaultRequisitioningBU": null,
     "DefaultRequisitioningBUId": null,
     "DefaultPrinter": null
		}
		]
	}
}
]
}

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


{
"parts": [
{
"id": "part1",
"path": "/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation": "get"
"payload" : {
"AssignmentId": 20000000000587,
  "Agent": "Brown, John",
  "AgentId": 8156,
  "AgentEmail": "john.brown@example.com",
  "ProcurementBU": "Vision Services",
  "ProcurementBUId": 458,
  "Status" : "Active",
  "StatusCode" : "Y",
  "DefaultRequisitioningBU" : null,
	...
	}
},
},
{
"id": "part2",
"path": "/procurementAgents",
"operation": "create",
"payload" : {
  "AssignmentId" : 300100124649102,
  "Agent" : "Johnson, Richard",
  "AgentId" : 300100008259523,
  "AgentEmail" : "richard.johnson@example.com",
  "ProcurementBU" : "Vision Operations",
  "ProcurementBUId" : 1016,
  "Status" : "Active",
  "StatusCode" : "Y",
  "DefaultRequisitioningBU" : null,
  "DefaultRequisitioningBUId" : null,
  "DefaultPrinter" : null,
	...
	}
}
]
}

Example: Retrieving an Existing Procurement Agent and Updating Another Procurement Agent

This request retrieves an existing procurement agent and updates the details of another procurement agent:

curl \
https://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": "/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation": "get"
},
{
"id": "part2",
"path": "/procurementAgents/20000000000613",
"operation": "update",
"payload": {
           "Agent" : "Johnson, John",
           "Status": "Inactive",
	}
}
]
}

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


{
"parts":[
{
"id":"part1",
"path":"/procurementAgents/?q=AgentEmail='john.brown@example.com'",
"operation":"get",
"payload" :{
  "AssignmentId": 20000000000587,
  "Agent": "Brown, John",
  "AgentId": 8156,
  "AgentEmail": "john.brown@example.com",
  "ProcurementBU": "Vision Services",
  "ProcurementBUId": 458,
  "Status" : "Active",
  "StatusCode" : "Y",
	...
	}
}, 
{
"id" : "part2",
"path" : "/procurementAgents/20000000000613",
"operation" : "update",
"payload" : {
  "AssignmentId" : 20000000000613,
  "Agent" : "Johnson, John",
  "AgentId" : 132,
  "AgentEmail" : "john.johnson@example.com",
  "ProcurementBU" : "Vision Operations",
  "ProcurementBUId" : 100000010018224,
  "Status" : "Inactive",
	...
	} 
}
]
}

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.