Asynchronous responses with Prefer:respond-async
Sometimes the work you are asking VersionOne to perform can take a long time. Some HTTP clients will time out when a request takes too long, and sometimes you'd just rather fire-and-forget, and then callback later to find the result. The Batch API takes a page out of the OData spec to enable you to specify your preference for asynchronous responses.
Quickstart: specifying Prefer:respond-async
To tell VersionOne to execute your request asynchronously, pass an HTTP header Prefer:respond-async
, like this:
curl -i -X POST \
-H "Content-Type:text/yaml" \
-H "Prefer:respond-async" \
-H "Authorization:Basic YWRtaW46YWRtaW4=" \
-d \
'from: Story
set:
Status: Done' \
'http://localhost/VersionOne.Web/api/asset'
You should then get a response like this:
{
"requestId": "ab3483fd-0427-4530-a29a-118dd1775b13",
"message": "Your request has been accepted and is being processed. You can query for the results at this URL: http://localhost/VersionOne.Web/api/asset/result/ab3483fd-0427-4530-a29a-118dd1775b13.",
"resultUrl": "http://localhost/VersionOne.Web/api/asset/result/ab3483fd-0427-4530-a29a-118dd1775b13"
}
If you follow the resultUrl
, then while the request is still processing, you'll see a response like this:
{
"requestId": "ab3483fd-0427-4530-a29a-118dd1775b13",
"createdDate": "2017-04-06T00:50:34.4947817Z",
"completedDate": "0001-01-01T00:00:00Z",
"duration": "00:00:00",
"durationSeconds": 0.0,
"complete": false,
"processing": true,
"assetsCreated": {
"oidTokens": [],
"count": -1
},
"assetsModified": {
"oidTokens": [],
"count": -1
},
"assetsOperatedOn": {
"oidTokens": [],
"count": -1
},
"queryResult": {
"results": [],
"count": -1
}
}
And, when the request completes, you'll see something like this:
{
"requestId": "ab3483fd-0427-4530-a29a-118dd1775b13",
"createdDate": "2017-04-06T00:50:34.4947817Z",
"completedDate": "2017-04-06T00:52:51.9260657Z",
"duration": "00:02:17.4312840",
"durationSeconds": 137.431284,
"complete": true,
"processing": false,
"assetsCreated": {
"oidTokens": [],
"count": 0
},
"assetsModified": {
"oidTokens": [
"Story:3906",
"Story:3907",
"Story:3908",
// thousands more...
"Story:10936",
"Story:10943",
"Story:10948"
],
"count": 6892
},
"assetsOperatedOn": {
"oidTokens": [],
"count": 0
},
"queryResult": {
"results": [],
"count": -1
}
}