Batch Calls

Batch calls can create and list objects collectively. This means that, for example, a single request can create multiple objects, or return information on any number of objects in an isolated form.

To make this type of call, you will use the POST method, as well as specific information in the header and body of the request.

 

URL

{RMUrl}/api/ batch

 

REQUEST METHOD

POST

 

VARIABLES AND FIELDS FOR THE HEADER

Content-Type (Required): Must be completed with the following value: multipart/mixed; boundary="batch_test_boundary". You can define the value of the "batch_test_boundary" field. It will be used again in the header to separate the various requests in the body.

X-Transactional-Batch (Optional): If this field is not declared, all the requests in the body of the request will be executed individually. In other words, if one fails, it will not prevent the others from being executed. If this field is used, all calls will be made at once, meaning that if one of the requests in the body fails, all of them will fail (POST method). This field accepts the values "Sequential" or "NonSequential", which determine how the requests will be executed. Note that this field is not valid for the GET method.

 

SPECIFIC DATA FOR THE REQUEST BODY

In the request body, specify all the custom objects to be created and/or all the GET requests to be made. Each new request must begin with the separator defined in the header, as follows:

 

--batch_test_boundary

 

 

Next, the request for the object must be declared, as follows:

 

--batch_test_boundary

POST {RMUrl}/api/objects/object HTTP/1.1

Authorization: OAuth2 access_key

Content-Type: application/json; charset=utf-8

{"Name": "New Batch Object"}

 

 

And/or:

 

--batch_test_boundary

GET /{RMUrl}/api/objects/object HTTP/1.1

Authorization: OAuth2 access_key

 

 

At the beginning of each new request, a separator must be used, as in the examples above. When all requests in the body have been declared, the separator must be entered as follows to indicate the end of the request:

--batch_test_boundary--

 

REQUEST EXAMPLE

POST {RMUrl}/api/batch

 

HEADER

 

Content-Type: multipart/mixed; boundary="batch_test_boundary"

X-Transactional-Batch: Sequential

 

BODY

 

--batch_test_boundary

Content-Type: application/http; msgtype=request

 

POST /{RMUrl}/api/objects/object HTTP/1.1

Authorization: OAuth2 access key

Content-Type: application/json; charset=utf-8

 

{"Name": "New Batch Object"}

--batch_test_boundary

Content-Type: application/http; msgtype=request

 

GET /{RMUrl}/api/objects/object HTTP/1.1

Authorization: OAuth2 access key

 

--batch_357647d1-a6b5-4e6a-aa73-edfc88d8866e--

 

SUCCESS RESPONSE

POST

HTTP/1.1 201 Created

Location: http://localhost/{RMUrl}/api/objects/ERMControl/44

1 – ID of the object created

 

GET

{ "DateCreated" : "/Date(1392028780953-0200)/",

  "DateUpdated" : "/Date(1392028780953-0200)/",

  "Deleted" : false,        

  "Description" : "New Object Description",

  "Id" : 1,

  "Name" : "New Object"

}