Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I'm trying to save a script in an app, via the REST API. However, everytime I do POST to /api/v1/apps/{id}/scripts ( ) it saves a new version of the script that shows up in the history. I would rather want to update the current script.
So, using PATCH to api/v1/apps/{id}/scripts/current - but cannot get it to work. I'm getting a 200 but nothing changes. Docs: https://qlik.dev/apis/rest/apps/#%23%2Fentries%2Fv1%2Fapps%2F-appId%2Fscripts%2F-version-patch
This is the REST call definition of my call (wget):
I've tried all kinds of syntax for the NxPatch structure in the body of the request, but cannot figure it out. I can't find any documentation of NxPatch and coming up short in my Devtools in browser.
Try enclosing your body in brackets ([]). Example:
.\curl.exe "https://<tenant>/api/v1/apps/<appid>/scripts/<scriptid>" -X PATCH -H "Authorization: Bearer <api key>" -H "Content-type: */*" -d '[{"op":"replace","path":"/versionMessage","value":"example3"}]'
It looks like the docs mistakenly don't express that the body needs to be array not a set of objects.
Hey Levi!
I did, but no change. I'm pretty sure the body content itself (NxPatch struct) is not in the right format to begin with. I'm i finding it hard to understand how it's supposed to be formatted. I've tried similar to these combinations:
[{ "op": "replace", "path": "/", "value": { "qScript": "///$tab Section\r\nNEW STUFF;"} };]
{ "Op": "replace", "Path": "/", "Value": { "qScript": "///$tab Section\r\nNEW STUFF;"} };
{ "Op": "replace", "Path": "/", "Value": "MY NEW SCRIPT" };
...and more. I just can't seem to get it to work..
NxPatch does not provide any specific example: https://qlik.dev/apis/rest/apps/#%23%2Fdefinitions%2FNxPatch
However, I'm pretty sure the operations are lowercase (or at least camelCase), given this: https://qlik.dev/apis/rest/apps/#%23%2Fdefinitions%2FNxPatchOperationType
Ok, I found something really confusing. I only get 200 OK, if I use (what I consider) a malformatted json..
This gives 200 OK, note the semi-colon outside of the last json bracket...
[{ "op": "replace", "path": "/", "value": { "qScript": "///$tab Section\r\nNEW STUFF;"} };]
However, this (without the last semi-colon) gives 500 INTERNAL ERROR:
[{ "op": "replace", "path": "/", "value": { "qScript": "///$tab Section\r\nNEW STUFF;"} } ]
That was a complete fluke, that I accidentally tried this.. but I can't explain it.
None of the requests changes anything.
Is my url correct? I'm just assuming that /current is what to put in for /{version} in the url, given that's what I use when using GET on /apps/id/scripts.