Look here for general information about the API usage:
https://developer.survalyzer.com/knowledge-base/authentication/
To connect QlikSense you can follow these steps:
Keep in mind that retrieving data using the Survalyzer NG API a is a 2-step process. First a connection is needed for retrieving an access token. Only after having created an access token the actual data connection can be set up.
With Survalyzer NG it is possible to use the cloud version of QlikSense.
Step 1: Retrieving the access token
First we need to add a new connection.
We need to choose “REST”:
The URL needs to be set to either:
for EU: https://api.survalyzer-eu.app
for Switzerland: https://api.survalyzer-swiss.app
To the URL we add the “call” we want to make. In this case we want first to retrieve a token, which authorizes us to retrieve data later:
https://api.survalyzer-swiss.app/publicapi/Authentication/v1/GetApiToken
The method for the request needs to be changed to “POST” and the post content may look like this (changed with your credentials):
{
"tenant":"mysubdomain",
"username":"myUsername",
"password":"myPassword"
}
And we add this query header:
After these settings are set you can test the connection. If everything was done correctly the following message should be shown:
You can click on “Create” now.
Step 2: Connecting to survey data
Open your app in QlikSense and open the data load editor:
We will now press the button “Select data” in the right sidebar (as shown in the screenshot):
This window should open, we select “root” and copy the token that gets displayed (maybe save it temporary in a small document somewhere):
Then we deselect the columns “isSucess”, “errorMessage” and “errorCode” and press “Insert script”. This will add the following script into the container:
We will need this for later, but will ignore it for now.
Next, we will click on “Create new connection” in the top right corner. This opens this window, where we will select “REST” again:
As URL we will define the call we want to do, in our example we call:
https://api.survalyzer-swiss.app/publicapi/Survey/v1/ReadSurveyDataCompact
Request method is POST, in our example the request contains a survey ID and a language:
{
"surveyId":"15",
"locale":"de"
}
And then we add the same query header as for the authorization call plus an additional header containing the authorization:
The value for “Authorization” is “Bearer [copied token]”. So in other words, right after the word “Bearer” and a space we paste the earlier copied token. (the token needs to be reset every 3 hours or it gets invalid)
When this is done we will test the connection. If it succeeds, so far everything is correct. We can click on “Create”.
Our Sidebar now contains 2 connections (one for the authorization and one for the data retreival):
Step 3: Setting up automatic authorization
To setup the automatic authorization we will now first add a snippet to the script we added in Step 1 to save the authorization token in a variable:
Let vAccessToken = Peek('accessToken',0,'RestConnectorMasterTable');
We paste it just before that table gets dropped:
Now we will add the definitions for our survey call. For that we will click the “Select data” button for the second data connection:
We select “root” on the left side and insert the script:
This adds the neccessary script to the system for the data:
Now we search for the following place in the script, which is in the end of the “SQL SELECT”:
FROM JSON (wrap on) "root" PK "__KEY_root";
We will replace this part with:
FROM JSON (wrap on) "root" PK "__KEY_root" WITH CONNECTION ( HTTPHEADER "Authorization" "Bearer $(vAccessToken)" );
With this setup in place QlikSense will always get a new token before receiving data from Survalyzer.
The same authorization bearer information would be needed for all calls that would be added to the project.
To load the data you can click on load data: