Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
We are trying to set up a change-owner script that allows us to import apps including meta data. The scenario is as follows: User imports an app, if there's metadata available (includes stream data and owner data), it checks wether the owner in the metadata exists in the current Qlik Environment. If so: It should change the owner.
Now I'm using this endpoint:
await _qrsClient.Put("/qrs/Selection/" + appID + "/App/synthetic?xrfkey=ABCDEFG123456789", content.ToString());
- appID = the id of the App to be changed.
- content (body)=
{[
{
"LatestModifiedDate": "2018-11-22T12:00:58.097Z",
"properties": {
"name": "owner",
"value": "a9d40139-cd13-467a-9147-ab167c51685a",
"valueIsModified": true
},
"type": "App"
}
]}
However, I get the following error:
The remote server returned an error: (400) Bad Request.
Could anyone point us in the right direction here?
Sure @joshuapierlo,
I'm going to abstract away from your particular code and point to the generic approach.
Get the details of the app we want to change: GET /qrs/app/055e0e8d-0f10-4d22-a175-62b05143347a
Response:
{
"id": "055e0e8d-0f10-4d22-a175-62b05143347a",
"createdDate": "2018-11-23T17:48:27.321Z",
"modifiedDate": "2018-11-23T17:49:26.141Z",
"modifiedByUserName": "QTSEL\\ltu",
"customProperties": [],
"owner": {
"id": "5334b296-493b-46ee-b621-79ba238ceb2c",
"userId": "sa_repository",
"userDirectory": "INTERNAL",
"name": "sa_repository",
"privileges": null
},
"name": "AppOwnerChangeDemo",
"appId": "",
"sourceAppId": "00000000-0000-0000-0000-000000000000",
"targetAppId": "00000000-0000-0000-0000-000000000000",
"publishTime": "1753-01-01T00:00:00Z",
"published": false,
"tags": [],
"description": "",
"stream": null,
"fileSize": 145970,
"lastReloadTime": "2018-07-24T13:14:06.545Z",
"thumbnail": "",
"savedInProductVersion": "12.108.7",
"migrationHash": "98d482c3f964dccf69cbfb9a00e0c048ea6eb221",
"dynamicColor": "",
"availabilityStatus": 0,
"privileges": null,
"schemaPath": "App"
}With this, we can see that the owner information is stored as an array inside the response.
Getting different user details (GET /qrs/user/full?filter=(name eq 'sa_api')😞
{
"id": "4b7a27e5-f1db-4cc2-be59-7c4086f7c1f6",
"createdDate": "2017-05-06T00:54:59.921Z",
"modifiedDate": "2017-05-06T00:54:59.921Z",
"modifiedByUserName": "INTERNAL\\bootstrap",
"customProperties": [],
"userId": "sa_api",
"userDirectory": "INTERNAL",
"name": "sa_api",
"roles": [],
"attributes": [],
"inactive": false,
"removedExternally": false,
"blacklisted": false,
"deleteProhibited": false,
"tags": [],
"privileges": null,
"schemaPath": "User"
}
Now changing the owner of the original app: PUT /qrs/app/055e0e8d-0f10-4d22-a175-62b05143347a
Body:
{
"id": "055e0e8d-0f10-4d22-a175-62b05143347a",
"createdDate": "2018-11-23T17:48:27.321Z",
"modifiedDate": "2018-11-23T17:49:26.141Z",
"modifiedByUserName": "QTSEL\\ltu",
"customProperties": [],
"owner": {
"id": "4b7a27e5-f1db-4cc2-be59-7c4086f7c1f6",
"userId": "sa_api",
"userDirectory": "INTERNAL",
"name": "sa_api",
"privileges": null
},
"name": "AppOwnerChangeDemo",
"appId": "",
"sourceAppId": "00000000-0000-0000-0000-000000000000",
"targetAppId": "00000000-0000-0000-0000-000000000000",
"publishTime": "1753-01-01T00:00:00Z",
"published": false,
"tags": [],
"description": "",
"stream": null,
"fileSize": 145970,
"lastReloadTime": "2018-07-24T13:14:06.545Z",
"thumbnail": "",
"savedInProductVersion": "12.108.7",
"migrationHash": "98d482c3f964dccf69cbfb9a00e0c048ea6eb221",
"dynamicColor": "",
"availabilityStatus": 0,
"privileges": null,
"schemaPath": "App"
}Hope that helps.
Sure @joshuapierlo,
I'm going to abstract away from your particular code and point to the generic approach.
Get the details of the app we want to change: GET /qrs/app/055e0e8d-0f10-4d22-a175-62b05143347a
Response:
{
"id": "055e0e8d-0f10-4d22-a175-62b05143347a",
"createdDate": "2018-11-23T17:48:27.321Z",
"modifiedDate": "2018-11-23T17:49:26.141Z",
"modifiedByUserName": "QTSEL\\ltu",
"customProperties": [],
"owner": {
"id": "5334b296-493b-46ee-b621-79ba238ceb2c",
"userId": "sa_repository",
"userDirectory": "INTERNAL",
"name": "sa_repository",
"privileges": null
},
"name": "AppOwnerChangeDemo",
"appId": "",
"sourceAppId": "00000000-0000-0000-0000-000000000000",
"targetAppId": "00000000-0000-0000-0000-000000000000",
"publishTime": "1753-01-01T00:00:00Z",
"published": false,
"tags": [],
"description": "",
"stream": null,
"fileSize": 145970,
"lastReloadTime": "2018-07-24T13:14:06.545Z",
"thumbnail": "",
"savedInProductVersion": "12.108.7",
"migrationHash": "98d482c3f964dccf69cbfb9a00e0c048ea6eb221",
"dynamicColor": "",
"availabilityStatus": 0,
"privileges": null,
"schemaPath": "App"
}With this, we can see that the owner information is stored as an array inside the response.
Getting different user details (GET /qrs/user/full?filter=(name eq 'sa_api')😞
{
"id": "4b7a27e5-f1db-4cc2-be59-7c4086f7c1f6",
"createdDate": "2017-05-06T00:54:59.921Z",
"modifiedDate": "2017-05-06T00:54:59.921Z",
"modifiedByUserName": "INTERNAL\\bootstrap",
"customProperties": [],
"userId": "sa_api",
"userDirectory": "INTERNAL",
"name": "sa_api",
"roles": [],
"attributes": [],
"inactive": false,
"removedExternally": false,
"blacklisted": false,
"deleteProhibited": false,
"tags": [],
"privileges": null,
"schemaPath": "User"
}
Now changing the owner of the original app: PUT /qrs/app/055e0e8d-0f10-4d22-a175-62b05143347a
Body:
{
"id": "055e0e8d-0f10-4d22-a175-62b05143347a",
"createdDate": "2018-11-23T17:48:27.321Z",
"modifiedDate": "2018-11-23T17:49:26.141Z",
"modifiedByUserName": "QTSEL\\ltu",
"customProperties": [],
"owner": {
"id": "4b7a27e5-f1db-4cc2-be59-7c4086f7c1f6",
"userId": "sa_api",
"userDirectory": "INTERNAL",
"name": "sa_api",
"privileges": null
},
"name": "AppOwnerChangeDemo",
"appId": "",
"sourceAppId": "00000000-0000-0000-0000-000000000000",
"targetAppId": "00000000-0000-0000-0000-000000000000",
"publishTime": "1753-01-01T00:00:00Z",
"published": false,
"tags": [],
"description": "",
"stream": null,
"fileSize": 145970,
"lastReloadTime": "2018-07-24T13:14:06.545Z",
"thumbnail": "",
"savedInProductVersion": "12.108.7",
"migrationHash": "98d482c3f964dccf69cbfb9a00e0c048ea6eb221",
"dynamicColor": "",
"availabilityStatus": 0,
"privileges": null,
"schemaPath": "App"
}Hope that helps.
Hi @Levi_Turner !
Thank you kindly for your response. I was out of the office for a few days...
My way of thinking was quite silly! Why would I create a new content object if I can just rip it from another app with the same owner.... Your method works perfectly fine!
Thanks a bunch 🙂