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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
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
MVP
MVP

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...

 

 

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.

View solution in original post

5 Replies
QFabian
MVP
MVP

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...

 

 

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
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
MVP
MVP

Excelent @elaineng , that is the idea!

Greetings!! Fabián Quezada (QFabian)
did it work for you? give like and mark the solution as accepted.
Riya07
Contributor II
Contributor II

Hi @QFabian ,

 

How did you convert all settings into parameters.

Could you please elaborate