Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
WernerDC
Creator
Creator

Retrieving data from an API

Hi Guys, I need to retrieve data from an API. Problem is I can only call the data weekly!

 

I have to go into the API to change the Date to the next week after every reload. How can I automate this? And is it possible when all the historic data is retrieved that I can reload the newest week each week?

 

Hope I make sense.

 

Kind regards

 

 

4 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Does the API dialog generate a FROM url/parameter for the Load statement?  If you will post that FROM we can help you with an expression to set it to a dynamic week.

-Rob

WernerDC
Creator
Creator
Author

 
WernerDC
Creator
Creator
Author

@rwunderlich see my script here.

pabloviera
Creator
Creator

Hello Werner you can loop API calls using the "WITH CONNECTION" feature of the script.

You need to delete the last semicolon and put your call with the variables inserted in the URL below, between parenthesis. Take a look at this example calling SAP HANA (You can nest loops of course)

for i=1 to 12
let vmonth=num($(i),'00');

RestConnectorMasterTable:
SQL SELECT
[...]
FROM XML "feed" PK "__KEY_feed"
WITH CONNECTION
(
URL "https://xxxxx-api.s4hana.ondemand.com/sap/opu/odata/sap/XXXXXXX/XXXXX?$filter=FiscalPeriod eq '$(vmonth)'");

next;

 

If it is a POST call, you need to add parameters in the section instead of in the URL, check Steve's Dark reply here

https://community.qlik.com/t5/Connectivity-Data-Prep/POST-Data-using-REST-Connector/td-p/1447843

 

Also an implementation using a variable filled with the entire request body:

https://community.qlik.com/t5/Connectivity-Data-Prep/REST-connection-POST-method-QlikSense/td-p/1216...

https://community.qlik.com/t5/Connectivity-Data-Prep/Qlik-Rest-Connector-Post-Method/td-p/1412475

 

Regards