Qlik Community

Connectivity & Data Prep

Discussion board where members can learn more about Qlik Sense Data Connectivity.

cancel
Showing results for 
Search instead for 
Did you mean: 
Restless
Partner
Partner

Load data from GraphQL API with REST data connector

Hi everyone!

 

I'm using Qlik Sense desktop and load data from an API using the REST connector. I cannot load all data at once, so I need to use  pagination. The challenge here is, that GraphQL is used as query language. 

My question is: How can I page data I load from a GraphQL endpoint when I have to pass the page information in the body of a POST request?

 

Some background information:

I send a POST request to an API endpoint and specify the data I want to be returned. This specification happens in the body of the request in the form of an stringified JavaScript object (JSON).

The answer as well is a JSON string containing the information I requested. I am mainly interested in content, but also requested pageInfo which contains hasNextPage (Bool) and totalCount (int).

The URL of the endpoint is always the same, no data is passed via URL. Pagination information cannot be sent via header (only Authorization, content-type,accept-language).  

The request itself works. I just don't know how to handle the pagination.In each query, I have to manipulate the body of the request, changing the '0' to the number of the page I request.

 

mongoproductsearch(page:{page:0 size:10})

 

Size is limited to 10.000. Currently, I would haveto do ~50 requests. 

 

Thanks!

Robin

 

GraphQL query and responseGraphQL query and response

 

REST ConnectorREST Connector

 

2019-03-19_14-13-32.png

Labels (1)
1 Solution

Accepted Solutions
Vu_Nguyen
Employee
Employee

Hi Robin, you can modify body of a REST connection during script execution using WITH CONNECTION keyword, which provides a BODY parameter. See https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/Load-R...
Vu Nguyen
If a post helps resolve your issue, please mark the answer as correct.

View solution in original post

2 Replies
Vu_Nguyen
Employee
Employee

Hi Robin, you can modify body of a REST connection during script execution using WITH CONNECTION keyword, which provides a BODY parameter. See https://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/Connectors_REST/Load-R...
Vu Nguyen
If a post helps resolve your issue, please mark the answer as correct.
Restless
Partner
Partner
Author

Hi, 

thanks, I was able to get it working using WITH CONNECTION.

This is my solution and what I learned on the way. In case someone stumbles upon this post:

  • I  use double quotes "" around the object property query and its value in the JSON string
  • In the query value itsself I use \"" to mask the quote

2019-04-04_12-16-25.png2019-04-04_12-17-16.png