Skip to main content
Nea
Visitor III
March 6, 2024
Solved

API v2 Adding user to a group

  • March 6, 2024
  • 3 replies
  • 2879 views

Hello,

 

Im trying to add the user: "user" to the group: "group1" using the api v2 of a fortigate v6.4.15

Below is my request with the return (200:OK) but no revision_change, so its doing nothing

Also below the GET requests on the user and group1 to show the configs

 

What am I missing ?

 

Thanks for reading !

 

 

 

curl -k -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer abcdefg" -d '{"member": "test"}' https://FORTI-URL/api/v2/cmdb/user/group/group1
{
"http_method":"PUT",
"revision":"5d01f6d0438463b2da7bd48c54508be3",
"revision_changed":false,
"mkey":"group1",
"status":"success",
"http_status":200,
"vdom":"root",
"path":"user",
"name":"group",
"serial":"FGT6xx",
"version":"v6.4.15",
"build":2095
}

 

 

 

 

curl -k -X GET -H "Content-Type: application/json" -H "Authorization: Bearer abcdefg" https://FORTI-URL/api/v2/cmdb/user/local/test
{
"http_method":"GET",
"revision":"5380e9e62a96d94149368f7c05789ab7",
"results":[
{
"name":"test",
"q_origin_key":"test",
"id":16777277,
"status":"enable",
"type":"password",
"passwd":"ENC XXXX",
"ldap-server":"",
"radius-server":"",
"tacacs+-server":"",
"two-factor":"disable",
"two-factor-authentication":"",
"two-factor-notification":"",
"fortitoken":"",
"email-to":"",
"sms-server":"fortiguard",
"sms-custom-server":"",
"sms-phone":"",
"passwd-policy":"",
"passwd-time":"2024-03-06 13:31:01",
"authtimeout":0,
"workstation":"",
"auth-concurrent-override":"disable",
"auth-concurrent-value":0,
"ppk-secret":"",
"ppk-identity":"",
"username-sensitivity":"enable"
}
],
"vdom":"root",
"path":"user",
"name":"local",
"mkey":"test",
"status":"success",
"http_status":200,
"serial":"FGT6xx",
"version":"v6.4.15",
"build":2095
}

 

 

 

 

curl -k -X GET -H "Content-Type: application/json" -H "Authorization: Bearer abcdefg" https://FORTI-URL/api/v2/cmdb/user/group/group1
{
"http_method":"GET",
"revision":"5d01f6d0438463b2da7bd48c54508be3",
"results":[
{
"name":"group1",
"q_origin_key":"group1",
"id":48,
"group-type":"firewall",
"authtimeout":0,
"auth-concurrent-override":"disable",
"auth-concurrent-value":0,
"http-digest-realm":"",
"sso-attribute-value":"",
"member":[
],
"match":[
],
"user-id":"email",
"password":"auto-generate",
"user-name":"disable",
"sponsor":"optional",
"company":"optional",
"email":"enable",
"mobile-phone":"disable",
"sms-server":"fortiguard",
"sms-custom-server":"",
"expire-type":"immediately",
"expire":14400,
"max-accounts":0,
"multiple-guest-add":"disable",
"guest":[
]
}
],
"vdom":"root",
"path":"user",
"name":"group",
"mkey":"group1",
"status":"success",
"http_status":200,
"serial":"FGT6xx",
"version":"v6.4.15",
"build":2095
}

Best answer by ozkanaltas

Hello @Nea ,

 

I think you need to add a "name" parameter in your request. Could you try this? I tried it in my lab. It works. 

 

 

 

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

 

3 replies

ozkanaltas
Valued Contributor III
March 6, 2024

Hello @Nea ,

 

I think you need to add a "name" parameter in your request. Could you try this? I tried it in my lab. It works. 

 

 

 

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

 

Nea
NeaAuthor
Visitor III
March 6, 2024

That's it !
Thank's a lot for your help and reactivity

Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!