Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
cesaraccardi
Specialist
Specialist

QRS API - updating users custom properties

Hello,

I have defined a custom property "Department" and associated to apps/users for access control. I would like to automate the process of going to QMC and manually setting the "Department" values for each user. I believe this should be possible using QRS API but as I don't have much experience with the API am not sure how to do this.

I am using Postman and managed to retrieve the details of a given user as well as the custom properties associated:

Request

GET /qrs/user/2e04436f-a71a-45c5-999c-793a00ba6a77/?Xrfkey=ABCDEFG123456789 HTTP/1.1

Host: myserver

X-Qlik-Xrfkey: ABCDEFG123456789

Response

json get user by id.PNG

In this case User 1 is associated to Finance and Sales, now let's say I wanted to move it to Executive and Sales. Can I just update the value of "Finance" to "Executive"? I have tried sending a PUT request like below but it doesn't work (it gives a 409 Conflict error message). Does anybody know why?


PUT /qrs/user/2e04436f-a71a-45c5-999c-793a00ba6a77?Xrfkey=ABCDEFG123456789 HTTP/1.1

Host: myserver

X-Qlik-Xrfkey: ABCDEFG123456789

Content-Type: application/json

{

  "id": "2e04436f-a71a-45c5-999c-793a00ba6a77",

"customProperties": [

    {

      "id": "fb5e68ec-d382-4bd1-b9f3-81c5a5f1b3e1",

      "value": "Executive"

    }

  ]

}

Thanks in advance,

Cesar

15 Replies
cesaraccardi
Specialist
Specialist
Author

Thanks for sharing that Toni, I will start using the modifiedDate from QRS from now on.

Not applicable

Hello Cesar,

I have been wrestling with the same problem for days. Your approach gave me great hints!

I think basically if we need to do any POST requests with QRS API, we need the modifiedDate field in the data model.

Thanks a lot!

Mengyi

cesaraccardi
Specialist
Specialist
Author

Hi Yuan,

I am glad to see that this post has proven to be helpful to you, wish you luck on your implementation!

Cheers,

Cesar

mbj
Employee
Employee

hey guys, great discussion.

I created a little example to help others

```

createCustomProperty('testBies', [1, 2]);

export function createCustomProperty(name, choiceValues = ['no values initialized']) {

   var customProperty = {

   "name": name,

   "valueType": "Text",

   "objectTypes": ["App", "ContentLibrary", "DataConnection", "ReloadTask", "Stream", "User"],

   "choiceValues": choiceValues

  }

   var result = qrs.post('/qrs/CustomPropertyDefinition', null, customProperty)

   console.log('result of create custom property: ', result)


   result.name = 'UpdatedName';

   var result = qrs.put('/qrs/CustomPropertyDefinition/' + result.id, null, result)

   console.log('result after update', result)

}

```

PS: You can find a lot of API documentation in the slide generator on http://integration.qlik.com/slides

Anonymous
Not applicable

Hey Cesar,

Can we fetch User wise assigned custom properties from Qliksense Server using QRS API?

You can look into this which I have posted:

Custom Properties for Users using QRS API's

Pls Suggest.

Regards,

Balraj Ahlawat

bekahbeets
Creator
Creator

I am getting either a 409 or a 400 exception when I run the following PUT command. I mainly get a "Received error code: 400::The "GetAllByMany" operation failed" error.

What is weird is I get a response with the apps data when I comment out the customProperties attribute. When i add in the customproperties attribute and json, i get the error.

 

Put('/app/' + appId,
{

"modifiedDate": lastModifiedDate, 
"modifiedByUserName": "instance////un",
"customProperties": [
{
"modifiedDate": lastModifiedDate,
"modifiedByUserName":  "instance////un",
"value": 'Node C'
}
] 
},
'json'