Troubleshooting Tip: FortiGate API access
Description
This article describes the integration with FortiGate. In this integration, API access is used for the following functions:
- Reading MAC Address Tables (L2 Poll).
- Reading IP Tables (L3 Poll).
- Reading VLANs.
- Switching VLANs.
- Populating the Network inventory with the FortiSwitch and FortiAP it manages.
If the API communication is not working properly, these functions will fail.
Scope
FortiNAC.
Solution
> HTTP/1.1 200 OK
Date: Fri, 04 Oct 2019 12:50:02 GMT
Server:
Set-Cookie: APSCOOKIE_1504669070="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Set-Cookie: VDOM_1504669070="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Set-Cookie: CENTRAL_MGMT_OVERRIDE_1504669070="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Set-Cookie: EDIT_HISTORY_1504669070="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Set-Cookie: FILE_DOWNLOADING_1504669070="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Set-Cookie: csrftoken_1504669070="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Set-Cookie: ccsrftoken_1504669070="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Set-Cookie: ccsrftoken="0%260"; path=/; expires=Thu, 16-Oct-1969 12:50:02 GMT; secure; SameSite=Strict
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
X-Frame-Options: SAMEORIGIN
Content-Security-Policy: frame-ancestors 'self'
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=15552000
X-UA-Compatible: IE=Edge
- Verify the API port used in the FortiGate model (443 by default) matches the value in the FortiGate configuration.
- In the FortiGate UI, navigate to System -> Settings. The HTTPS port is listed under Administration Settings.
- In FortiNAC, the port can be verified by running the following command from CLI:
get system global | grep admin-sport
admin-sport : 443
management-port-use-admin-sport: disable
execute enter-shell
device -ip 10.20.30.1 -SetAttr -name API_Port -value 4443
Note:
- If API ports match, verify the port is not getting blocked somewhere in the network.
- Verify credentials are correct. In the Administration UI, navigate to Network Devices -> Topology.
- Select the Credentials tab for the FortiGate model.
- Select Validate Credentials.
device -ip <FortiGate IP> -SetAttr -name APIToken -value <API Key>
On FortiNAC-OS, run the following command:
execute enter-shell
$ device -ip <FortiGate IP> -SetAttr -name APIToken -value <API Key>
3. If the API call is still failing, check if HTTPS is enabled specifically on the FortiGate interface to which the API call is being made.
FortiGate# show system interface port<>
edit "port<>" <----- The specific port to which API calls are to be made.
set ip <FortiGate-IP>
set allowaccess ping https ssh fgfm <--- Should have https enabled, else API calls fail to this FortiGate-IP.
...
next
end
Related documents:
FortiGate endpoint management integration guide
FortiGate Endpoint Management Integration
Technical Tip: How to configure & use API token to communicate with FortiGate
Technical Tip: How to fix REST API Failure.
