Consider a situation when you need to create a resource or perform an action and the operation takes a long time to complete (e.g: a publication of a Tracking Configuration). The request will return a status 303 See Other
with a background_job
resource URL to monitor progress. A background_job
resource will always return 3 fields has_finished
, status
and message
. The client shall query the job URL regularly until the has_finished
attribute returns true.
The status
attribute can have the following possible values:
- success
- failure
- In progress
In case of failure
, the message
attribute will contain the error details, otherwise can be ignored.
The following diagram illustrates the publication of a Tracking Configuration:
Examples
Example of the publication request
curl -v -X POST --header 'Content-Type: application/json' --header 'Accept: application/vnd.api+json' --header 'Authorization: {authentication_key}' 'https://www.nao-cloud.com/api/v2/sites/910/asset_tracking_config/publish'
Example of the redirection response
< HTTP/1.1 303 See Other < Date: Mon, 09 Aug 2021 15:48:41 GMT < Location: https://www.nao-cloud.com/api/v2/background_jobs/48156 < Other headers....
Example of the query to monitor job progress
curl -X GET --header 'Accept: application/vnd.api+json' --header 'Authorization: 9w_6TxzzRUXtyGViiHM6g_cDf3sMFw' 'https://www.nao-cloud.com/api/v2/background_jobs/48145'
Example of the job failure
{ "data": { "id": "48145", "type": "job_watcher", "attributes": { "id": 48145, "name": null, "description": null, "status": "failure", "message": "Missing graph or indoor area. Please add.", "has_finished": true } } }
Example of the job success
{ "data": { "id": "48145", "type": "job_watcher", "attributes": { "id": 48145, "name": null, "description": null, "status": "success", "message": "success", "has_finished": true } } }