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...
Nominating a forum post submits a request to create a new Knowledge Article based on the forum post topic. Please ensure your nomination includes a solution within the reply.
The 401 response code is most likely caused by invalid API key (access_token).
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:
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
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..
You can’t set 0.0.0.0, when you use api key, try to set specific host.
Select Forum Responses to become Knowledge Articles!
Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.
User | Count |
---|---|
1517 | |
1013 | |
749 | |
443 | |
209 |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2024 Fortinet, Inc. All Rights Reserved.