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: 
Sbalijepalli
Employee
Employee

REST Connection

Hello I am new to Qliksense and trying to understand how can I do a rest connection to get full data loaded.

I succeeded until certain point where my data is populating partially but not fully, I understand I need to play around with having headers in a certain way.. But not sure where can I start at.

Any references are appreciated. 

Although I have 100s of records, every time I try loading or connecting, I am getting restricted to only 12

Labels (3)
7 Replies
David_Friend
Support
Support

@Sbalijepalli that almost looks like a preview or something, are you following:

https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/Create...

also what version is QS?

Dataintellinalytics

HI,

Might be your API source got some limit set to serve only 12 records. You may have to implement pagination and loop to fetch next set of 12 records, repeat until you fetch all 100 records.

JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @Sbalijepalli 

What is the API that you are reading - I can have a look at how the pagination works. Most API's have a different method of how they handle the pagination. Some use parameters like limit and offset some use a Page_size and Page parameter, etc etc

Regards Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn

Sbalijepalli
Employee
Employee
Author

Hello I am using custom Pagination type. 

https://{subdomain}.peakon.com/api/v1/actions/contexts/

Subdomain & contextId are custom values

Sbalijepalli
Employee
Employee
Author

Hi, even when I am using postman I am seeing only 12 records, so pagination is what i was thinking on making the changes

Sbalijepalli
Employee
Employee
Author

HI David, Thank you for the referrence, I was following the same steps on the setup but still confused on how I can use the query headers/query parameters & pagination

JandreKillianRIC
Partner Ambassador
Partner Ambassador

Hi @Sbalijepalli 

Based on the documentation you need 2 query parameters. 

JandreKillianRIC_0-1737959955366.png

Your first read might be startIndex 1 and count 50, Next read will be startIndex 51 count 50. and so on. 

What I normally do is for loop where I take the total results (Should be in the root table) and do a ceil(Totalcount/Count) 

In this example it would look something like this 

Root table with totalResults. 

JandreKillianRIC_1-1737960076857.png

Make sure you allow WITH CONNECTION 

JandreKillianRIC_2-1737960268417.png

LIB CONNECT TO 'TestAPI';

RestConnectorMasterTable:
SQL SELECT 
	"count",
	"next",
	"previous",
	"__KEY_root",
	(SELECT 
		"id" AS "id_u0",
		"company",
		"email_opted_in",
		"email_status",
				"__KEY_contacts",
		"__FK_contacts",
		(SELECT 
			"@Value",
			"__FK_tag_ids"
		FROM "tag_ids" FK "__FK_tag_ids" ArrayValueAlias "@Value"),
		(SELECT 
			"email",
			"field",
			"__FK_email_addresses"
		FROM "email_addresses" FK "__FK_email_addresses"),
		(SELECT 
			"line1",
			"line2",
			"country_code",
			"__FK_addresses"
		FROM "addresses" FK "__FK_addresses"),
		(SELECT 
			"number",
			"extension",
			"field" AS "field_u1",
			"type",
			"number_e164",
			"__FK_phone_numbers"
		FROM "phone_numbers" FK "__FK_phone_numbers"),
		(SELECT 
			"id",
			"company_name",
			"__FK_company"
		FROM "company" FK "__FK_company")
	FROM "contacts" PK "__KEY_contacts" FK "__FK_contacts")
FROM JSON (wrap on) "root" PK "__KEY_root";


[root]:
LOAD	
	[startIndex],
	[totalResults],
	[__KEY_root]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);

Set zCount = 50; 
Let zTotalResults = Peek('totalResults'); 
Let zForCount = $(zTotalResults)/$(zCount);

Drop Table RestConnectorMasterTable; 

For i = 1 to $(zForCount)

// Add all your JSON script stuff here again using with connection

	Let zStartIndex = ($(i)-1) * $(zCount) + 1;

    SELECT 
                xxx, 
                xxxx, 
                xxxx, 
                xxxx, 
                "__FK_company"
            FROM "company" FK "__FK_company")
        FROM "contacts" PK "__KEY_contacts" FK "__FK_contacts")
    FROM JSON (wrap on) "root" PK "__KEY_root"
    With Connection (
    QUERY "startIndex" "$(zStartIndex)",
    QUERY "count" "$(zCount)"
    );

Next i; 

// Below the for will be all your residents loads from the RestConnectorMasterTable 

 

Regards - Jandre

Mark the solution as accepted that solved your problem and if you found it useful, press the like button! Check out my YouTube Channel | Follow me on LinkedIn