Skip to main content
GeorgeFLopes
Visitor III
Mar 26, 2024 12:44 AM UTC
Solved

FortiOS API - addgrp

Hello,

 

Could someone give me one help?

 

Made this request to my fortinet, gives 200 but looking at console, not works.

 

curl -k -X PUT --location "https://*****/api/v2/cmdb/firewall/addrgrp/OFF" \
--insecure \
-H "Authorization: Bearer ****" \
--header 'Content-Type: application/json' \
--request PUT \
--data-raw '
{
"method": "PUT",
"url": "/api/v2/cmdb/firewall/addrgrp/OFF",
"params": {
"datasource": true,
"with_meta": true,
"vdom": "root"
},
"data": {
"member": [
{
"name": "X.X.X.1"
}
]
}
}'
{
"http_method":"PUT",
"revision":"519**",
"revision_changed":false,
"mkey":"TAOFF",
"status":"success",
"http_status":200,
"vdom":"root",
"path":"firewall",
"name":"addrgrp",
"serial":"FG*",
"version":"v7.4.3",
"build":2573
}%

GeorgeFLopes
Visitor III
Mar 26, 2024 6:45 PM UTC

This worked for me, thx

 

curl --location "https://***.***.***.***/api/v2/cmdb/firewall/addrgrp/GROUPNAME/member" --insecure -H "Authorization: Bearer **********" --header 'Content-Type: application/json' --request POST --data-raw '

{"name":"10.10.10.10"}

'

 

curl --location "https://***.***.***.***/api/v2/cmdb/firewall/addrgrp/GROUPNAME/member/10.10.10.10" --insecure -H "Authorization: Bearer ****" --header 'Content-Type: application/json' --request DELETE

 

curl --location "hhttps://***.***.***.***/api/v2/cmdb/firewall/addrgrp/GROUPNAME/member/" --insecure -H "Authorization: Bearer ****" --header 'Content-Type: application/json' --request GET

5 replies

rtanagras
Staff & Editor
Staff & Editor
Mar 26, 2024 1:59 AM UTC

Hi @GeorgeFLopes - can you try this CURL command?

curl -k --location "https://******/api/v2/cmdb/firewall/addrgrp/OFF" \
--insecure \
-H "Authorization: Bearer ***" \
-H "Content-Type: application/json" \
--data-raw '{
"method": "PUT",
"params": {
"datasource": true,
"with_meta": true,
"vdom": "root"
},
"data": {
"member": [
{
"name": "X.X.X.1"
}
]
}
}'

just replace ****** with your actual URL and *** with your actual Authorization token.

GeorgeFLopes
Visitor III
Mar 26, 2024 12:16 PM UTC

Hey, Sure,

 
Output
  "status":"error",
  "http_status":405,
  "path":"firewall",
  "name":"addrgrp",
  "mkey":"OFF",
  "serial":"FGT*****",
  "version":"v7.4.3",
  "build":2573,
  "http_method":"POST"
rtanagras
Staff & Editor
Staff & Editor
Mar 26, 2024 2:36 PM UTC

Hi @GeorgeFLopes - Before you run the commands again, did you remove the existing members of your OFF address group?

 

You can check by using 'show firewall addrgrp | grep OFF'.

 

The PUT method is used to update or modify an existing address group. If you want to create a new one, use POST. To better understand the behavior of modifying an existing address group, try clicking on API Preview or inspecting your browser before clicking the OK button. You can also use 'httpsd -1' to see its behavior.

Here, maybe this link would help you: https://community.fortinet.com/t5/Support-Forum/Fortigate-API-Remove-address-from-group-address/m-p/210541#M192910

ozkanaltas
Valued Contributor III
Mar 26, 2024 6:29 PM UTC

Hello @GeorgeFLopes ,

 

Can you try like this.Without "data"

 

{     "member": [       {         "name": "xxx_user_name"       }     ]   } }

 

GeorgeFLopes
GeorgeFLopesAuthorAnswer
Visitor III
Mar 26, 2024 6:45 PM UTC

This worked for me, thx

 

curl --location "https://***.***.***.***/api/v2/cmdb/firewall/addrgrp/GROUPNAME/member" --insecure -H "Authorization: Bearer **********" --header 'Content-Type: application/json' --request POST --data-raw '

{"name":"10.10.10.10"}

'

 

curl --location "https://***.***.***.***/api/v2/cmdb/firewall/addrgrp/GROUPNAME/member/10.10.10.10" --insecure -H "Authorization: Bearer ****" --header 'Content-Type: application/json' --request DELETE

 

curl --location "hhttps://***.***.***.***/api/v2/cmdb/firewall/addrgrp/GROUPNAME/member/" --insecure -H "Authorization: Bearer ****" --header 'Content-Type: application/json' --request GET

Thought Leadership. Security Summit. Thursday, November 12th, PGA National Resort, Palm Beach Gardens, FL.
Security Operations Summit: Modernize SecOps. Operate AI-Native.AMER: November 4 | 9:00 AM PST. India and SAARC: November 5 | 10:00 AM IST. EMEA: November 5 | 10:30 AM CET. APAC: November 5 | 11:00 AM SGT