Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Highlighted
Partner
Partner

Use of variables in rest connection.

Hi,

I'm using a REST connection to get my data. But I create for each end point a new connection.

See the picture below:
My first connection is to https://test.webshop.nl/api/data/v4.1/customer
My second connection is to https://test.webshop.nl/api/data/v4.1/address
My third connection is to https://test.webshop.nl/api/data/v4.1/shipto

Is there a possibility to use a variable, something like https://test.webshop.nl/api/data/v4.1/$(V_connnection)
Or is there a smarter solution.

Please let me know.
Wouter

Rest_connection.JPG

Labels (1)
1 Solution

Accepted Solutions
ChiragPradhan
Contributor II

Re: Use of variables in rest connection.

Hi,

Once you have connected to the API,

You could something like this -

Let V_Connection = 'Customer';
Let vURL = '<a href="https://test.webshop.nl/api/data/v4.1/" target="_blank">https://test.webshop.nl/api/data/v4.1/</a>' & V_Connection;

Trace $(vURL);

RestConnectorMasterTable:
SQL SELECT 
	'
    '
    '
    '
FROM JSON (wrap on) "root"
WITH CONNECTION(Url "$(vURL)");
;

[root]:
LOAD
	'
	"
    "
    "
    "
    '
RESIDENT RestConnectorMasterTable;


DROP TABLE RestConnectorMasterTable;

 

If it is what you are looking for, please consider marking it as resolved.

Regards,

Chirag

2 Replies
ChiragPradhan
Contributor II

Re: Use of variables in rest connection.

Hi,

Once you have connected to the API,

You could something like this -

Let V_Connection = 'Customer';
Let vURL = '<a href="https://test.webshop.nl/api/data/v4.1/" target="_blank">https://test.webshop.nl/api/data/v4.1/</a>' & V_Connection;

Trace $(vURL);

RestConnectorMasterTable:
SQL SELECT 
	'
    '
    '
    '
FROM JSON (wrap on) "root"
WITH CONNECTION(Url "$(vURL)");
;

[root]:
LOAD
	'
	"
    "
    "
    "
    '
RESIDENT RestConnectorMasterTable;


DROP TABLE RestConnectorMasterTable;

 

If it is what you are looking for, please consider marking it as resolved.

Regards,

Chirag

Partner
Partner

Re: Use of variables in rest connection.

Yes it works for me.
Sometimes it's easier to create the connection in QlikView and load the data. Copy the of the script code to your Sense Solution. You can use the end of the connection part of the code for the variable V_Connection.

Wouter