Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
bramkn
Partner - Specialist
Partner - Specialist

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
Øystein_Kolsrud
Employee
Employee

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

bramkn
Partner - Specialist
Partner - Specialist
Author

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.

Øystein_Kolsrud
Employee
Employee

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...

bramkn
Partner - Specialist
Partner - Specialist
Author

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