Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
gabriel_v
Participant

add tags to an existing user.

Hello everyone, I'm trying to add tags to existing ( or new ) users via the web api and I'm facing the following errors.

1) /web_api/v1.1/set-tag 

request

{
"uid" : "5fa2f623-8dd1-472b-b7b6-6d444f3dcd33",
"tags" : {
"add" : "tag3"
}
}

response

{
"code": "generic_err_object_type_wrong",
"message": "The UID value '5fa2f623-8dd1-472b-b7b6-6d444f3dcd33' belongs to an object that is not compatible with this API"
}

2) web_api/v1.1/set-generic-object

request

{
"uid" : "3a3cc4cd-7169-42a7-9037-3516933b5fbd",
"tags": { "add": "tag3" }
}

response

{
"code": "generic_server_error",
"message": "Management server failed to execute command"
}

3)  web_api/v1.1/set-generic-object 

request

{
"uid" : "3a3cc4cd-7169-42a7-9037-3516933b5fbd",
"tags": ["tag3"]
}

Response
{
"code": "generic_server_error",
"message": "Management server failed to execute command"
}

4) web_api/v1.1/add-generic-object

Request

{
"create":"com.checkpoint.objects.classes.dummy.CpmiUser",
"name":"test-012",
"tags":["tag3"],
"userc":{
"create":"com.checkpoint.objects.classes.dummy.CpmiSpecificUserc",
"owned-object":{
"useGlobalEncryptionValues":"true",
"ike":{
"create":"com.checkpoint.objects.classes.dummy.CpmiSpecificUsercIke"
}
}
}
}

Response 

{
"code": "generic_server_error",
"message": "Management server failed to execute command"
}

is there any other option for create tags on users ?

any thoughts are welcome 🙂

0 Kudos
3 Replies
Maik
Advisor

One option would be to use the management CLI. In my example I added tags to a host object which is called "Test123" - the syntax for users should be the same.

> set host name "Test123" tags.1 "Tag1" tags.2 "Tag2" tags.3 "Tag3"

This command alters the host "Test123" by adding multiple tags to the related object - you will end up with Tag1, Tag2 & Tag3.

> set host name "Test123" tags.1 "Tag1"

This command sets only "Tag1" and deletes the other already set tags - so it overwrites existing ones. You end up with just Tag1.

> set host name "Test123" tags.add "Tag2"

This command adds "Tag2" so that you have Tag1 & Tag2 in the end.

If you want to directly access the web API via POST requests you need to fit the above commands in the related format. The management api reference guide shows you the correct syntax for this case.

Edit: Nevermind, I think you won't be able to edit host objects via the API - at least with the current release. The syntax of your first example should be correct. If we can trust the error message the API is not able to handle the object type - maybe Robert Decker‌ can help Smiley Happy

Edit 2: Just realized that there are generic-object API calls available, that allow the creation/alteration of users. Seems like the "tag" attribute has a special "path" to set tags in this case. Will try to find out more.

So "set tag" is an official API command that can not work with generic API created objects such a users. But even when I try to create a new user via generic API calls like e.g. this...

add generic-object create "com.checkpoint.objects.classes.dummy.CpmiUser" name "TestBot" email "myvpn@user.local" phoneNumber "01234 1337" tags "Tag1"

... I still receive an error regarding the "tags" parameter. Without this one the mentioned command works fine. "tags.1" or "tags.add" results in the same error, while tags.set shows the following:

message: "Unexpected JsonType 'STRING' found under set collection modifier. Expected type is an object with identifier of the changed owned object: 'uid' and fields which are going to be modified in the owned objects under the key: 'owned-object'. The modified object is stored in the collection: 'tags'"

Robert_Decker
Advisor

Hi,

Any legacy R77.X object that doesn't have Management API support, cannot be assigned tags via Generic Objects API.

This is because the Generic Objects API works with the old schema (same as dbedit API), and the tag objects are saved into R80.X databse.

Robert.

gabriel_v
Participant

Robert DeckerMaik Dummer‌ Thanks so much for the clarification !

0 Kudos

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events