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 an Existing Project, Creating a New Project, and Retrieving a Project Customer Details
This request retrieves an existing project, creates a new project, and retrieves a project customer details:
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": "/projects/100010025119098",
"operation": "get"
},
{
"id": "part2",
"path": "/projects/100010025119199",
"operation": "create",
"payload": {
"ProjectName": "Project_1",
"SourceTemplateId": 100000019578034,
"SourceTemplateName": "T, Consulting & Construction (VO)",
"ProjectStatus": "Approved",
"ProjectCalendarName": "Standard US Calendar",
}
]
}
}
{
"id": "part3",
"path": "/projects/100010025119098/child/ProjectCustomers/300100072928710",
"operation": "get"
}
]
}
The response body contains the result and uses the same media type as the request.
{
"parts": [
{
"id": "part1",
"path": "/projects/100010025119098",
"operation": "get"
"payload" : {
"ProjectCurrencyCode": "USD",
"ProjectDescription": "M6MAT-PRJ8",
"ProjectEndDate": "2010-05-01",
"ProjectId": 100010025119098,
"ProjectManagerEmail": null,
"ProjectManagerName": null,
"ProjectManagerResourceId": null,
"ProjectName": "M6MAT-PRJ8",
"ProjectNumber": "M6MAT-PRJ8",
"ProjectPlanViewAccessCode": "PLAN_VIEW_TEAM",
"ProjectPriorityCode": "HIGH",
"ProjectStartDate": "2008-04-01",
"ProjectStatus": "Approved",
"ProjectStatusCode": "APPROVED",
...
}
},
},
{
"id": "part2",
"path": "/projects/100010025119199",
"operation": "create",
"payload" : {
"ProjectCurrencyCode": "USD"
"ProjectDescription": "Contract and Capital Template with same line burdening"
"ProjectEndDate": null
"ProjectId": 100010025119199
"ProjectManagerEmail": null
"ProjectManagerName": null
"ProjectManagerResourceId": null
"ProjectName": "Project_1"
"ProjectNumber": "300100074907364"
"ProjectPriorityCode": null
"ProjectStartDate": "2015-12-02"
"ProjectStatus": "Approved"
"ProjectStatusCode": "APPROVED"
...
}
}
{
"id": "part3",
"path": "/projects/100010025119098/child/ProjectCustomers/300100072928710",
"operation": "get"
"payload" : {
"PartyId": 920497
"PartyNumber": "726233"
"PartyName": "AT & T"
"ProjectId": 300100072711280
"ProjectPartyId": 300100072928710
...
}
}
]
}
Example: Retrieving an Existing Project and Updating Another Project
This request retrieves an existing project and updates the details of another project:
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": "/projects/100010025119199",
"operation": "get"
},
{
"id": "part2",
"path": "/projects/100010025119098",
"operation": "update",
"payload": {
"ProjectDescription": "Real estate project implemented for a year."
}
}
]
}
The response body contains the result and uses the same media type as the request.
{
"parts":[
{
"id":"part1",
"path":"/projects/100010025119199",
"operation":"get",
"payload" :{
"ProjectCurrencyCode": "USD"
"ProjectDescription": "Contract and Capital Template with same line burdening"
"ProjectEndDate": null
"ProjectId": 100010025119199
"ProjectManagerEmail": null
"ProjectManagerName": null
"ProjectManagerResourceId": null
"ProjectName": "Project_1"
"ProjectNumber": "300100074907364"
"ProjectPriorityCode": null
"ProjectStartDate": "2015-12-02"
"ProjectStatus": "Approved"
"ProjectStatusCode": "APPROVED"
...
}
}
},
{
"id" : "part2",
"path" : "/projects/100010025119098",
"operation" : "update",
"payload" : {
"ProjectCurrencyCode": "USD",
"ProjectDescription": "M6MAT-PRJ8",
"ProjectEndDate": "2010-05-01",
"ProjectId": 100010025119098,
"ProjectManagerEmail": null,
"ProjectManagerName": null,
"ProjectManagerResourceId": null,
"ProjectName": "M6MAT-PRJ8",
"ProjectNumber": "M6MAT-PRJ8",
"ProjectPlanViewAccessCode": "PLAN_VIEW_TEAM",
"ProjectPriorityCode": "HIGH",
"ProjectStartDate": "2008-04-01",
"ProjectStatus": "Approved",
"ProjectStatusCode": "APPROVED",
...
}
}
}
]
}
Batch processes help you get tasks done more quickly and efficiently.