7. Asynchronous Processing

7. Asynchronous Processing

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_finishedstatus 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
     }
  }
}

    • Related Articles

    • NAO Track configuration publication

      After the NAO Cloud configuration has been updated, a publication is required before the changes are taken into account in production. The publication is an asynchronous process, meaning that it will take time and does not return an immediate ...
    • Release 21.09 (NAO SDK 4.11)

      Versions Component Version Hotfix Hotfix 21.09.01 NAO® Cloud 21.09.0 21.09.01 NAO® SDK iOS 4.11.3 4.11.4 4.11.5 NAO® SDK Android 4.11.3 4.11.4 4.11.5 NAO® Logger iOS 4.11.3 4.11.4 4.11.5 NAO® Logger Android 4.11.3 4.11.4 4.11.5 New Features NAO® SDK ...
    • 5. Creating, Updating and Deleting Resources

      NAO Cloud allows resources of a given type to be created and allows some existing resources to be modified or deleted. A request either succeeds or fails atomically (in a single “transaction”). No partial updates are allowed. Creating Resources A ...
    • Release 4.4

      Release V4.4.7 Date: 16 November 2017 Build: V4.4.7-R20218 New Features [Android 8] Add SDK interface [wakeUpNotification] to allow client to customize the application wake-up notification Fixed Issues [iOS] Fix crashes setPowerMode reported by ...