Technical Tip: How to monitor a task via the FortiManager API
Description
This article describes how to monitor a task via the FortiManager API.
Scope
FortiManager.
Solution
For API calls that require additional processing time, FortiManager immediately returns a task ID. This task ID can be used to track the progress of the operation and obtain its final status.
The JSON-RPC URL is:
/task/task/<id>
Task monitoring is performed using the JSON-RPC get method.
For example, to monitor task ID 222:
Request:
{ "id": 1, "method": "get", "params": [ { "url": "/task/task/222" } ], "session": <Session_ID>, "verbose": 1 }
Response:
{ "id": 1, "result": [ { "data": { "adom": 111, "end_tm": 151515151, "flags": 0, "history": [ { "detail": "2018-01-12 02:13:44:start to install dev(FG600C-194-77)", "name": "FG600C-194-77", "percent": 0, "vdom": null }, { "detail": "2018-01-12 02:13:46:init state: start to get pre-checksum", "name": "FG600C-194-77", "percent": 15, "vdom": null }, ], "id": 2066, "line": [ { "detail": "install and save finished status=OK", "err": 0, "ip": null, "name": "FG600C-194-77", "oid": 366, "percent": 100, "state": "done", "vdom": null }, { "detail": "Installation to real device done", "err": 0, "ip": "192.168.194.77", "name": "FG600C-194-77(root)[copy]", "oid": 366, "percent": 100, "state": "done", "vdom": "root" } ], "start_tm": 151515151, "state": "done", "title": "Install Device", "tot_percent": 200, "user": "admin" }, "status": { "code": 0, "message": "OK" }, "url": "/task/task/222" } ] }
Related documents:
