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

API v2 Adding user to a group

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
}

1 Solution
ozkanaltas
Valued Contributor III

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"
      }
    ]
  }
}

 

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
2 REPLIES 2
ozkanaltas
Valued Contributor III

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"
      }
    ]
  }
}

 

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
Nea
New Contributor

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

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