Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Eshwar1
Contributor III
Contributor III

Issue with Dynamic REST API Call Using "WITH CONNECTION" in Qlik Sense

Hi Everyone,

I am trying to load data from the following API endpoint using the Qlik REST Connector:
API URL: https://disease.sh/v3/covid-19/countries/USA

Implementation Details:

  • I created a REST API Connection in Qlik Sense named 'CovidAPI'.
  • I defined a variable vCountry to dynamically pass the country parameter.
  • In the front-end, I created an input variable (vCountry) where users can select different country values (e.g., 'USA', 'India', 'UK').
  • I also added a button to reload the app when a new country is selected.

 

My Script:

SET vCountry = 'USA';  // Default Country

LIB CONNECT TO 'CovidAPI';

CovidData:

SQL SELECT

    "country",

    "cases",

    "recovered"

FROM JSON (wrap on) "root"

WITH CONNECTION (

    URL "https://disease.sh/v3/covid-19/countries/$(vCountry)"

);

 

Issue:

When I select a different country (e.g., 'India' or 'UK') from the input variable and click the reload button, the table chart is not updating to reflect the selected country’s data. It still shows the previously loaded data.

Troubleshooting Done:

Checked if "WITH CONNECTION" is enabled in the REST Connector settings.
 Verified that vCountry is updating correctly in the Variable Editor.
 Manually running the script with a hardcoded country (e.g., SET vCountry = 'India';) works fine.

Questions:

  1. Is there a better way to dynamically pass the country parameter in the API request?
  2. Does Qlik Sense cache API responses, and how can I force a fresh reload?
  3. Is there a workaround if "WITH CONNECTION" is not working dynamically?

 

Any insights or alternative approaches would be greatly appreciated!

Thanks in advance!

 

Labels (2)
1 Solution

Accepted Solutions
marksouzacosta

Hi @Eshwar1,

In summary, you cannot set a variable in your Load Script. This Load Script variable will always have its value reset during the load process - unless you do some fancy logic. Instead of doing that, create a variable in your dashboard:

1. Create your variable in your User Interface. Click on the Variable button showed in the picture below and then click on Create new button.

marksouzacosta_0-1739993646347.png

2. Now, use this new variable to setup the values from the User Interface. Every time you set it on the UI, it will be carried to your Load Script.

 

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

View solution in original post

3 Replies
marksouzacosta

Hi @Eshwar1,

In summary, you cannot set a variable in your Load Script. This Load Script variable will always have its value reset during the load process - unless you do some fancy logic. Instead of doing that, create a variable in your dashboard:

1. Create your variable in your User Interface. Click on the Variable button showed in the picture below and then click on Create new button.

marksouzacosta_0-1739993646347.png

2. Now, use this new variable to setup the values from the User Interface. Every time you set it on the UI, it will be carried to your Load Script.

 

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

Eshwar1
Contributor III
Contributor III
Author

Thank you Mark, its working now as expected.