Documentation
Sends batch request on the API.
All urls must be relative to the domain name
(http://api.wisembly.dev/app_dev.php/{this part}). Other urls will not
be recognized and will return a 400 instead.
Expected payload :
{
"batch": [
{
"method": "POST",
"uri": "/batch",
"body": "{\"batch\": [{\"method\": \"GET\", \"uri\": \"/api/5/authentication\"}]}",
"headers": {
"Content-Type": "application/json"
}
},
{
"method": "POST",
"uri": "/batch",
"parameters": {
"batch": [
{
"method": "GET",
"uri": "/api/5/authentication"
}
]
}
}
]
}
So in the payload, as long as there is one request and at a most a
predefined number of requests (20 at the time of writing this
documentation), it will always return a 200, even if one or more
sub-request fails (they will have their proper status code).
When sending a body in a POST / PUT request, it must be encoded as a
string, and the appropriate header must be sent on that particular
request (see example above).
For the above payload, here is the expected response :
[
{
"body": "[{\"body\":\"...\"}]
"code": 200
},
{
"body": "[{\"body\":\"...\"}]
"code": 200
}
]
As you can see, the response has the body already encoded (so you will
need to decode it), like in a request where it has to be encoded
when sending a body.
This feature is closely following the batch api requests by facebook :
https://developers.facebook.com/docs/graph-api/making-multiple-requests
Status Codes
Status Code |
Description |
200 |
|
400 |
- Not enough requests in the batch attribute
- No batch attribute
- No array in the batch attribute
- Too many requests
|