
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Qlik sense Rest API issue - Internal server error.
Hi All,
I am trying to connect Rest API.
I am able to fetch tokens and data successfully.
But now I need to fetch token dynamically, so that I am passing the vales in variables.
I am using the code as per below,
Variable-
vToken =''Token value
vAPI_Link = 'Passing the API link from where we need to fetch the data'
Condition in load data statement.
FROM CSV (header on, delimiter ",", quote """") "CSV_source"
WITH CONNECTION (URL "$(vAPI_Link)",
HTTPHEADER "accept" "text/csv",
HTTPHEADER "Authorization" "Bearer $(vToken)"
);
However, I am getting an error as per the below,
Can you please suggest on this

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perhaps one of these might help..
Kind regards...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @deep2021
Are you saying that if you configure the REST connection it works but if you add the WITH CONNECTION to make it dynamic it fails ?
I did a quick thest as follows and it worked for me:
Variables:
set vAPI_Link= 'https://<mytenant>.us.qlikcloud.com/api/v1/users';
set vToken = '<mytoken>';
Connection details:
WITH CONNECTION (URL "$(vAPI_Link)",
HTTPHEADER "Authorization" "Bearer $(vToken)"
);
Could it be that one of the values from the variables is incorrect?
Maybe you can test without variables first to verify the values are correct and then replace one by one the variables.
Hope it helps!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @NadiaB
I can access the token successfully and able to fetch in the variable.
Below is the snapshot for the same,
But in the second part while accessing the data I do not know where it is going wrong.
We are using Qliksense on prem.
I am not getting the below link,
set vAPI_Link= 'https://<mytenant>.us.qlikcloud.com/api/v1/users';
For fetching the data I am using the link like below,
vAPI_Link = link that I used in Postman.
and below is the snap for connection string, that I am using,
Thanks,
Deep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @deep2021
I would suggest to test with the REST connector alone first, use the preview option to get the query and execute it, after that works fine then start making changes.
The picture doesn't show much to troubleshoot, other option would be to test from Postman and verify the values that are passed are correct.
500 is a generic error, you would need to get the response and the descriptive error to see what is missing, probably Postman will generate a more descriptive error if you test with it .
Hope it helps.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In Postman and in qlik I am able to fetch the data successfully
In Postman I used below parameters and same I used in qlik,
Token URL-
Body URL to fetch Token info-
URL to fetch Data and values that I passed highlighted in yellow-
The same parameters are also working fine in qlik but while passing these values in variables and in automations it throws an error.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
After passing the token value in variable it is working fine.
I am using variable like below,
LET vToken ='Token Value'
But whenevr I am trying to retrive token value from code,
it is showing me the below error,
Could you please suggest me on this.
I am using the below code,
LET vToken_API = 'Conn string name';
/* Token Generation Sub Routine Code */
SUB Get_Token
LIB CONNECT TO '$(vToken_API)';
RestConnectorMasterTable:
SQL SELECT
"access_token",
"expires_in",
"scope",
"jti",
"token_type",
"refresh_token"
FROM JSON (wrap on) "root";
TOKEN:
LOAD
[access_token],
[expires_in],
[scope],
[jti],
[token_type],
[refresh_token]
RESIDENT RestConnectorMasterTable;
DROP TABLE RestConnectorMasterTable;
let vToken = Peek('access_token',0,'TOKEN');
//TRACE token=[$(vToken)];
TRACE token=$(vToken);
Drop Table TOKEN;
ENDSUB
Call Get_Token
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @deep2021
It's hard to analyze without having the actual connection to test against, the following post has a document that describes step by step how to accomplish what you are looking for:
Hope it helps!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Now I am able to fetch the data. Can you please suggest how to use paging in qlik to fetch a number of files that holds data from rest API?
I have head endpoint to get total count of files. For paging I need to skip some parameters ,and limitation is that I can fetch only 100000 records in one request.
Can you please share the example?
Thanks
