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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
olgaavalos
Partner - Contributor III
Partner - Contributor III

API Rest - Qlik Integration

Hi,

I have an API that in the body request receives a csv file to execute. It works correctly in Postman, when integrating with Qlik it gives me errors. How do I enter in the body request that it calls a csv?

 

WITH CONNECTION (
Url "$(url)",
HTTPHEADER "Content-Type" "form-data",
BODY "C:/domuntes/data.csv");

Labels (3)
1 Reply
cristianj23a
Partner - Creator III
Partner - Creator III

Hi, In Qlik Sense, you can use the LIB CONNECT TO statement to create a connection to the API and then use the LOAD statement with the REST prefix to send the CSV file in the body of the request. Here's how you can do it:

LIB CONNECT TO 'YourConnectionName'; // Replace 'YourConnectionName' with the name of your connection in Qlik Sense

LOAD
*
FROM [YourApiEndpoint]
(ooxml, embedded labels, table is [YourTableName]);

// Replace 'YourApiEndpoint' with the API endpoint URL and 'YourTableName' with the table name or a suitable name for your data.

Ensure that the connection in Qlik Sense is set up correctly, and you have the appropriate access permissions to call the API and read the CSV file. If you are still facing errors, make sure to check the API documentation and the error messages in Qlik Sense for more details on the issue.

Additionally, if your API requires the file to be sent as form-data, you may need to add the necessary headers to the LIB CONNECT TO statement. Here's an example of how it can be done:

LIB CONNECT TO 'YourConnectionName'
WITH CONNECTION (
URL "$(url)",
HTTPHEADER "Content-Type" "multipart/form-data; boundary=YourBoundary",
HTTPHEADER "Authorization" "Bearer YourAccessToken",
BODY "$(Include=..\data.csv)" // This will load the data from the data.csv file located in the parent folder.
);

Replace 'YourBoundary' with the appropriate boundary for your API, and 'YourAccessToken' with the required authentication token if needed.

Please note that the exact syntax and setup may vary depending on the specific API you are working with. Make sure to refer to the API documentation and consult with your API provider for any specific requirements or configurations.

Regarts.

 

https://www.linkedin.com/in/cristianjorge/
Do not forget to mark as "Accepted Solution" the comment that resolves the doubt.