Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
elaineng
Contributor III
Contributor III

REST connector with date parameters

I'm using REST connect in Qlik Sense to import data from another application tp Qlik. This connections works successfully, but I need to specify a data range for API to work property.

I need to specify the start date and end date via request body.

API method: post 

Request Body:
{ "query": "query {buyer(data: {startDate: \"30-Nov-2022\", endDate: \"2-Dec-2022\"} ) { name, id}}"}

elaineng_0-1672916140301.png

I would like to know is there any alternative which I can specify the parameters in QS script to replace the RequestBody.

Labels (5)
1 Solution

Accepted Solutions
QFabian
Specialist III
Specialist III

Hi @elaineng , in your script, you can try the WITH CONNECTION keyword

WITH CONNECTION keyword

The REST Connector supports the WITH CONNECTION keyword, which can be used to override URLs, query parameters and query headers in a connection. The POST body can also be overridden when the POST method has been selected for the connection. WITH CONNECTION allows you to alter some parts of a connection rather than create a separate connection.

Four parameters can be used with the WITH CONNECTION keyword:

  • URL
  • QUERY
  • HTTPHEADER
  • BODY

The syntax for each parameter is:

  • URL "new url"
  • QUERY "parameter name" "parameter value"
  • HTTPHEADER "header name" "header value"
  • BODY "request body text"

Examples:  

WITH CONNECTION (

Url "https://localhost:81/northwind2.xml",

QUERY "type" "XML",

QUERY "size" "",

HTTPHEADER "auth_type" "token",

HTTPHEADER "token" "1234123123123",

BODY "Post this");

 

https://community.qlik.com/t5/Design/REST-connector-Using-WITH-CONNECTION/ba-p/1523257

 

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

 

 

QFabian

View solution in original post

5 Replies
QFabian
Specialist III
Specialist III

Hi @elaineng , in your script, you can try the WITH CONNECTION keyword

WITH CONNECTION keyword

The REST Connector supports the WITH CONNECTION keyword, which can be used to override URLs, query parameters and query headers in a connection. The POST body can also be overridden when the POST method has been selected for the connection. WITH CONNECTION allows you to alter some parts of a connection rather than create a separate connection.

Four parameters can be used with the WITH CONNECTION keyword:

  • URL
  • QUERY
  • HTTPHEADER
  • BODY

The syntax for each parameter is:

  • URL "new url"
  • QUERY "parameter name" "parameter value"
  • HTTPHEADER "header name" "header value"
  • BODY "request body text"

Examples:  

WITH CONNECTION (

Url "https://localhost:81/northwind2.xml",

QUERY "type" "XML",

QUERY "size" "",

HTTPHEADER "auth_type" "token",

HTTPHEADER "token" "1234123123123",

BODY "Post this");

 

https://community.qlik.com/t5/Design/REST-connector-Using-WITH-CONNECTION/ba-p/1523257

 

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

 

 

QFabian
elaineng
Contributor III
Contributor III
Author

Thanks for the info & link. However, after added with connection as below. QS script loaded 0 row.

I have no error during load and there are information is I load with connection string.

elaineng_0-1672995287692.png

 

elaineng
Contributor III
Contributor III
Author

I have managed to load the data after convert all settings into parameters. Thanks.

QFabian
Specialist III
Specialist III

Excelent @elaineng , that is the idea!

QFabian
Riya07
Contributor II
Contributor II

Hi @QFabian ,

 

How did you convert all settings into parameters.

Could you please elaborate