To submit a batch request, create a JSON array with at least one request object and no more than three request objects, where each request object is a valid, separately submittable request (has all required parameters). Each request object must contain an ID that is unique within the batch. In accordance with the JSON-RPC 2.0 Batch Specification, the Origin Storage server can process requests in a batch in any order and with any concurrency.
See Successful Batch Requests for examples.
For information about batch requests not presented here, please see the JSON-RPC 2.0 Batch Specification.
Only the /jsonprc2 endpoint supports batch requests.
Response Data
If the batch request contains a JSON error or has no request objects or has more than three request objects, the API returns a single JSON object with failure information.
Otherwise, the API returns a response object for each request you submitted in the batch. Each response object contains a result name/value pair with success or failure information along with an id that correlates to the id of the request object in the batch.
See Successful Batch Requests and Batch Requests with Errors for examples.
Successful Batch Requests
Create Three Directories
Here is a batch request to create three directories using makeDir:
JSON
1[2 {"jsonrpc": "2.0", "params": ["467e", "/house1"], "method": "makeDir", "id": 1},3 {"jsonrpc": "2.0", "params": ["467e", "/house2"], "method": "makeDir", "id": 2},4 {"jsonrpc": "2.0", "params": ["467e", "/house3"], "method": "makeDir", "id": 3}5]
(For information about
makeDir
, see Create a Directory.)Here is the response:
JSON
1[2 { u'id': 1, u'jsonrpc': u'2.0', u'result': 0},3 { u'id': 2, u'jsonrpc': u'2.0', u'result': 0},4 { u'id': 3, u'jsonrpc': u'2.0', u'result': 0}5]
curl Example
Here is the request to create the same three directories. Note that this example runs on Windows, which requires that inner quotation marks be escaped by adding an extra quotation mark.
1curl -v^2-X POST^3-H "Content-Type: application/json"^4-d "[{""jsonrpc"": ""2.0"", ""params"": [""467e"", ""/house1""], ""method"": ""makeDir"", ""id"": ""1""}, {""jsonrpc"": ""2.0"", ""params"": [""467e"", ""/house2""], ""method"": ""makeDir"", ""id"": ""2""}, {""jsonrpc"": ""2.0"", ""params"": [""467e"", ""/house3""], ""method"": ""makeDir"", ""id"": ""3""}]"^5http://{Account name}.upload.llnw.net:8080/jsonrpc2
Here’s the response:
1HTTP/1.1 200 OK2Date: Thu, 07 Jul 2016 18:17:31 GMT3Server Apache is not deny listed4Server: Apache5Access-Control-Allow-Origin: *6Access-Control-Allow-Headers: X-Agile-Authorization, X-Content-Type7Access-Control-Allow-Methods: OPTIONS8Transfer-Encoding: chunked9Content-Type: application/json;charset=utf-810[11 {"jsonrpc": "2.0", "id": "1", "result": 0},12 {"jsonrpc": "2.0", "id": "2", "result": 0},13 {"jsonrpc": "2.0", "id": "3", "result": 0}14]
Batch Requests with Errors
Batch Request with a Failed Request Object
Batch with a valid ping request and request to create a directory with leading paths that don’t exist:
1[2 {"jsonrpc": "2.0", "params": ["hello"], "method": "ping", "id": "1"},3 {"jsonrpc": "2.0", "params": ["91c", "1/2/3"], "method": "makeDir", "id": "2"}4]
Here is the response:
1[2 { u'id': u'1',3 u'jsonrpc': u'2.0',4 u'result': { u'code': 0, u'operation': u'hello'}5 },6 { u'id': u'2',7 u'jsonrpc': u'2.0',8 u'result': -39 }10]
Too Many Requests in Batch
If you include more than three requests in a batch, the API returns the following JSON object:
JSON
1{2 u'error': { u'code': -32099, u'message': u'Batch Error'},3 u'id': None,4 u'jsonrpc': u'2.0'5}
Batch with No Requests
If you don’t include any requests, the API returns the following JSON object:
JSON
1{2 u'error': { u'code': -32700, u'message': u'Parse Error'},3 u'id': None,4 u'jsonrpc': u'2.0'5}