- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Forigate 6.0.10 API python return code 401
Hello,
I Using the next python code:
import requests
import json
api_url='https://x.x.x.x/api/v2/monitor/system/config/backup?scope=global&access_token=MYTOKEN'
requests.packages.urllib3.disable_warnings()
data=requests.get(api_url,verify=False)
print(data.status_code)
print(data)
'''Get license status'''
when i run this code i get error code 401
for the API profile i allowed read/write.
Please someone can share with me python code that work with fortigate API ?
and why my code is not working...
- Labels:
-
FortiGate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The 401 response code is most likely caused by invalid API key (access_token).
Boris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I run the following debug commands:
(global) # diagnose debug resetA
(global) # diagnose debug enable
(global) # diagnose debug application httpsd -1
Debug messages will be on for 30 minutes.
I get errror : Peer not trusted:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you connecting to the API from a trusted host?
Reference: https://docs.fortinet.com/document/fortigate/6.0.0/cookbook/222079/using-a-trusted-host-optional
Boris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes for the check i configure 0.0.0.0
Also if i copy the api request and put it on my browser this work.
If i run the api request from python i get error..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can’t set 0.0.0.0, when you use api key, try to set specific host.
Lucas
