Fortinet black logo

REST API Solution Guide

Example API calls

Example API calls

For the purpose of these examples, cURL is being used to make the requests. cURL is more flexible than a browser alone, is cross platform and can be called from most scripts. It is not as flexible as native scripting languages but is a good clear example which can be used to understand how the API functions.

The following flags are used in the cURL query:

  • -kIgnore certificate errors - This can be overcome with use of a valid certificate.
  • -vVerbose - Increase the level of logging information (useful for debugging).
  • -uUser - Login information in the format USER[:PASSWORD].

When using PUT/POST with cURL on Windows, problems can be encountered with escaping of the required double quotes in the data content, leading to errors related to incomplete closed brackets. To avoid this, the code should be properly escaped (using \ before any double quotes) or the data text stored in a file and referenced using:

-d @<filename>

Alternatively, it is highly recommended that this is run on a Linux OS, where escaping of characters in cURL is more predictable.

Example API calls

For the purpose of these examples, cURL is being used to make the requests. cURL is more flexible than a browser alone, is cross platform and can be called from most scripts. It is not as flexible as native scripting languages but is a good clear example which can be used to understand how the API functions.

The following flags are used in the cURL query:

  • -kIgnore certificate errors - This can be overcome with use of a valid certificate.
  • -vVerbose - Increase the level of logging information (useful for debugging).
  • -uUser - Login information in the format USER[:PASSWORD].

When using PUT/POST with cURL on Windows, problems can be encountered with escaping of the required double quotes in the data content, leading to errors related to incomplete closed brackets. To avoid this, the code should be properly escaped (using \ before any double quotes) or the data text stored in a file and referenced using:

-d @<filename>

Alternatively, it is highly recommended that this is run on a Linux OS, where escaping of characters in cURL is more predictable.