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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
THIB49
Contributor
Contributor

HOW-TO READ HEADER IN API REST RESPONSE

Hello, i'm using an REST API call in my script with a standard SQL SELECT statement, but my API using response HEADER with totalcount and offset to manage pagination.

How can i read those response header from my script ?

Thanks T.

 

 

Labels (3)
2 Replies
robert_mika
Master III
Master III

 

I guess you setup is simile to the one I use to do

I would to to the table set up in the connection and look at the structure.

Then

1. Set up your REST connection with pagination type set to Custom.

The try to play with offset and loops

SET vOffset = 0;
SET vPageSize = 100;

Data:
LOAD *
FROM [Your Connection]
WITH CONNECTION (
URL "https://your.api.endpoint?offset=$(vOffset)&limit=$(vPageSize)"
);

LET vRowCount = NoOfRows('Data');

IF $(vRowCount) = 0 THEN
EXIT Do
ENDIF

Concatenate(MainTable)
LOAD * RESIDENT Data;

DROP TABLE Data;

LET vOffset = $(vOffset) + $(vPageSize);

Loop

THIB49
Contributor
Contributor
Author

Thank for your answer, i had test this way but my api always return rows  by cycling over the data. So i can't use NoOfRows to determinate the end, I've to read an header in response call 'x-pagination-size' who content the total count of rows in data.

Do you have an idea to read response header ?

T.