| Before taking any of the steps below, obtain the JSON API Session ID. Note: The session ID will be used in following JSON API request. { "id": 1, "method": "exec", "params": [{ "data": { "user": "{{admin}}", "passwd": "{{password}}" }, "url": "/sys/login/user" }] } Step 1: Retrieve FortiGate 'Device Name' in FortiManager. - (Body): JSON API.
{ "id": 1 "method": "get", "params": [ { "url": "/dvmdb/device" } ], "session": "{{session}}", "verbose": 1, } - (Scripts): Script to store 'Device Name' into variable 'device_targets'.
// Parse response JSON let response = pm.response.json(); // Filter out devices with os_type === "faz" let filteredDevices = response.result[0].data.filter(device => device.os_type !== "faz"); // Extract device names and prefix with "device/" let deviceTargets = filteredDevices.map(device => `device/${device.name}`); // Log it console.log("Device targets (excluding 'faz'):", deviceTargets); // Store JSON string in collection variable pm.collectionVariables.set("device_targets", JSON.stringify(deviceTargets)); Example:  Step 2: Get Administrator details: - Use the following JSON API request to get all fields:
{ "id": "2", "method": "exec", "params": [ { "url": "sys/proxy/json", "data": { "target": {{device_targets}}, "action": "get", "resource": "/api/v2/cmdb/system/admin" } } ], "session": "{{session}}" } - Use the following JSON API request to get only certain fields. Example: 'name' & 'accprofile'.
{ "id": "2", "method": "exec", "params": [ { "url": "sys/proxy/json", "data": { "target": {{device_targets}}, "action": "get", "resource": "/api/v2/cmdb/system/admin?format=name|accprofile" } } ], "session": "{{session}}" } Example:  - (Optional) Update the results in table format using scripts:
For example:  Note: The attached Postman collection contains the JSON and scripts used in this article. Troubleshooting: The following commands can be used on the FortiManager CLI to debug the API Calls: diagnose debug service httpd 255 diagnose debug service main 255 diagnose debug enable Related documents: |