Authentication
Before you use other REST API URLs, you must make an HTTP POST request to log in at the authentication URL.
| HTTP Methods |
|
| URL | https://HOST_OR_IP/api/v1/AdminLogin/ |
| Request JSON | {
"name": "YOUR_ACCOUNT",
"password": "YOUR_PASSWORD"
}
|
Use an account name that is allowed to use REST API access, and has permissions for the URLs that you will use. If the account does not have the required permissions, then it is indicated by the HTTP response code and body.
If the login succeeds, then the response contains a header with:
Set-Cookie: APSCOOKIE_...
Save and include this cookie value as a header in later REST API requests. This associates the requests with the existing authentication session.
Idle authentication sessions time out. See the idle timeout in the FortiRecorder Administration Guide. To continue using the REST API, authenticate again.
For example, to log in, you could open the command prompt on your computer and enter a curl command:
curl -H "Content-Type: application/json" -X POST -d "{\"name\":\"YOUR_ACCOUNT\",\"password\":\"YOUR_PASSWORD\"}" https://HOST_OR_IP/api/v1/AdminLogin -c cookie.txt
and then subsequent commands would include (-b) and possibly also update (-c) the session cookie file:
curl -X GET -b cookie.txt -c cookie.txt https://HOST_OR_IP/api/v1/SysStatusSysinfo
|
|
Do not save passwords in unencrypted files, including the CLI history log. Unencrypted credentials at rest are a security risk. If an attacker or virus compromises your computer, it could allow unauthorized persons to access your FortiRecorder system. Use a key management system, such as Vault in Postman, to securely store credentials. |
|
|
On Microsoft Windows with Command Prompt, inside the JSON data, you must put a backslash before each double straight quote ( -d "{\"name\":\"admin\"}" Alternatively, you can input a JSON stream from another command. URLs with parameters may also require double quotes around them. If you do not, then the command line may interpret each JSON attribute as CLI commands or arguments, resulting in various error messages depending on the sequential order of arguments and attributes. Reserved characters and escape sequences vary by operating system and command line environment; Linux and Mac terminals often do not require this, and Microsoft PowerShell uses different escape sequences. |
|
|
If you have either:
then authentication of all HTTPS requests might fail with certificate errors. Trust the FortiRecorder certificate or its signing CA. Do not use insecure ( For example, you could use certutil on the Windows command line: .\certutil.exe -addstore -f "Root" "C:\Users\YOUR_USERNAME\Downloads\FORTIRECORDER_CA_CHAIN.pem" and then use that root CA trust store with Secure HTTPS requests should fail if the FortiRecorder X.509 certificate is:
See also how to use certificates in the FortiRecorder Administration Guide. |