Skip to main content
iyotov
Staff
Staff
October 23, 2024

Technical Tip: How to retrieve config from multiple managed FortiGates using the FortiManager JSON API

  • October 23, 2024
  • 0 replies
  • 1005 views
Description

 

This article describes the API endpoint and options necessary to trigger a retrieve config operation in the FortiManager Device Manager.

It assumes that the user already knows how to use the JSON API in general, and how to authenticate and generate the session ID used in the example.

 

Scope

 

FortiManager.

 

Solution

 

This API call retrieves config from 10 of the managed FortiGates in the ADOM 'TEST'.

 

Sample request:

 

{

  "id": 3,

  "method": "exec",

  "params": [

    {

      "data": {

        "adom": "TEST",

        "flags": [

          "create_task",

          "nonblocking"

        ],

        "reload-dev-member-list": [

          {

            "name": "FortiGate-01"

          },

          {

            "name": "FortiGate-02"

          },

          {

            "name": "FortiGate-03"

          },

          {

            "name": "FortiGate-04"

          },

          {

            "name": "FortiGate-05"

          },

          {

            "name": "FortiGate-06"

          },

          {

            "name": "FortiGate-07"

          },

          {

            "name": "FortiGate-08"

          },

          {

            "name": "FortiGate-09"

          },

          {

            "name": "FortiGate-10"

          }

        ]

      },

      "url": "/dvm/cmd/reload/dev-list"

    }

  ],

  "session": "{{sessionid}}"

}

 

  • The 'create_task' flag creates a task that allows monitoring of the progress in the FortiManager GUI (under System Settings -> Task Monitor).
  • With the 'nonblocking' flag, the response is returned immediately, before the task is complete, since retrieving many devices may take some time.

 

Sample response:

 

{

  "id": 3,

  "result": [

    {

      "data": {

        "pid": 23223,

        "taskid": 321

      },

      "status": {

        "code": 0,

        "message": "OK"

      },

      "url": "/dvm/cmd/reload/dev-list"

    }

  ]

}

 

Related documents: