Qlik Community

Qlik Sense Integration, Extensions, & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

b_knuever
Contributor III

Can't get the qlik rest api to post in script

Hi,

I would like to do a POST call from the sense script editor.

I can get a GET call to work, but I can't figure out how to do a POST as the rest connector gives the error that you have to do a GET call first. When I try to do this in script with the "With connection" I can not get it to work. Not even with the original GET URL, it is not accepted. And I can't find a way to change the Method to POST. I have tried HTTPMethode and methode.

So I am stuck and can't find any documentation that I can use.

Can anyone give me an example or documentation with an example to fix this?

I am trying to Create Custom properties on the same sense server and with a Root admin account.

4 Replies
Employee
Employee

Re: Can't get the qlik rest api to post in script

Not sure what environment you are working in, but I believe you have to get the cookie from the GET call and include it in your POST request. This is an example in C#:

https://github.com/kolsrud/qlik_rest_sdk/blob/master/Qlik.Sense.RestClient/RestClient.cs#L80

As you can see it collects the cookie if it has not already done so. And the cookie collection simply implies running a dummy GET operation:

https://github.com/kolsrud/qlik_rest_sdk/blob/master/Qlik.Sense.RestClient/RestClient.cs#L124

The real work is done in this method that handles the setup of the requests (that's where the cookie container is configured):

https://github.com/kolsrud/qlik_rest_sdk/blob/master/Qlik.Sense.RestClient/RestClient.cs#L150

b_knuever
Contributor III

Re: Can't get the qlik rest api to post in script

I am working in Qlik script editor.

The documentation doesn't specify anything about a cookie as far as I know.

With the NPrinting api I needed to take part of the cookie returned in the header. This cookie is a lot smaller and I am not sure if this would work.

Also how do I get a post call in the script as I can only create GET calls. So I guess I have to change it with the With connection statement, can't figure out how.

Ill try to just put in the whole cookie.

Employee
Employee

Re: Can't get the qlik rest api to post in script

Ah, sorry... Should have read your original post better. I'm not familiar with that part of the script framework, so I'm probably not of much help here...

b_knuever
Contributor III

Re: Can't get the qlik rest api to post in script

Ah ok, thanks anyways. Hopefully someone else can help me.

Community Browser