Support Forum
The Forums are a place to find answers on a range of Fortinet products from peers and product experts.
Rostislav000
New Contributor II

How I can send cli command with rest api?

I need to get full configuration from fortigate 600E with REST API. I want to know how send cli command with rest api. Maybe I can use post method for send cli command? Or u tell me other ways to do it with rest api. Thanks 

1 Solution
ozkanaltas
Valued Contributor III

Hello @Rostislav000 ,

 

You can't send cli commands to FortiGate via the API interface. FortiGate API has different API call URLs.

 

If you want to download the backup file via API you can use this request for that. 

 

https://x.x.x.x/api/v2/cmdb/system/config/backup?scope=global&access_token=<Your_ACCESS_TOKEN_HERE>

 

Otherwise, you cannot get the entire configuration as API response output. If you want this, you need to call all API URL from FortiGate.

 

Also, I found one github link about that. You can use it if it works for you.

 

https://github.com/mcarneir0/fortigate-backup-api

If you have found a solution, please like and accept it to make it easily accessible to others.
NSE 4-5-6-7 OT Sec - ENT FW

View solution in original post

If you have found a solution, please like and accept it to make it easily accessible to others.NSE 4-5-6-7 OT Sec - ENT FW
5 REPLIES 5
ozkanaltas
Valued Contributor III

Hello @Rostislav000 ,

 

You can't send cli commands to FortiGate via the API interface. FortiGate API has different API call URLs.

 

If you want to download the backup file via API you can use this request for that. 

 

https://x.x.x.x/api/v2/cmdb/system/config/backup?scope=global&access_token=<Your_ACCESS_TOKEN_HERE>

 

Otherwise, you cannot get the entire configuration as API response output. If you want this, you need to call all API URL from FortiGate.

 

Also, I found one github link about that. You can use it if it works for you.

 

https://github.com/mcarneir0/fortigate-backup-api

If you have found a solution, please like and accept it to make it easily accessible to others.
NSE 4-5-6-7 OT Sec - ENT FW
If you have found a solution, please like and accept it to make it easily accessible to others.NSE 4-5-6-7 OT Sec - ENT FW
Rostislav000

I  can check full configuration only with ssh?

ozkanaltas
Valued Contributor III

Yes. You are right. 

If you have found a solution, please like and accept it to make it easily accessible to others.
NSE 4-5-6-7 OT Sec - ENT FW
If you have found a solution, please like and accept it to make it easily accessible to others.NSE 4-5-6-7 OT Sec - ENT FW
Rostislav000

I use nornir_pyfgt for automated device management. But it turns out that you need to store login data (username, password) in a yaml file, which is not reliable. What can I do with this to store them in some kind of database?

ozkanaltas
Valued Contributor III

Actually i dont have any experience with that tool. You can modify your python code to store passwords securely.Or you'll need to find a different tool that works this way.

If you have found a solution, please like and accept it to make it easily accessible to others.
NSE 4-5-6-7 OT Sec - ENT FW
If you have found a solution, please like and accept it to make it easily accessible to others.NSE 4-5-6-7 OT Sec - ENT FW
Announcements
Check out our Community Chatter Blog! Click here to get involved
Labels
Top Kudoed Authors