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

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
}%

1 Solution
GeorgeFLopes
New Contributor II

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

View solution in original post

5 REPLIES 5
rtanagras
Staff
Staff

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.

Best,
Ricky
GeorgeFLopes

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

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/...

Best,
Ricky
ozkanaltas
Valued Contributor II

Hello @GeorgeFLopes ,

 

Can you try like this.Without "data"

 

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

 

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
GeorgeFLopes
New Contributor II

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

Announcements

Select Forum Responses to become Knowledge Articles!

Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.

Labels
Top Kudoed Authors