Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to pass parameters dynamically in rest connector in Qlik sense

I have set a variable in qlik sense . i have to pass this variable as query parameters in get method.

I tried to pass this variable . but getting @value .Its  not retrieving data from service. But when I pass hardcoded value ,

then getting result . Can anyone help me

1 Solution

Accepted Solutions
shraddha_g
Partner - Master III
Partner - Master III

http://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/1.1/Load-REST-data/Sele...

For Dynamic Parameters Refer Thread REST connector with automatic date update

You can try:

Let vProductId = 2;

RestConnectorMasterTable:

SQL SELECT 

    "CategoryName",

    "Name",

    "Price",

    "ProductId"

FROM JSON (wrap on) "root"

WITH CONNECTION ( 

QUERY "ProductId" "$(vProductId)")

;

[root]:

LOAD    [CategoryName] AS [CategoryName],

    [Name] AS [Name],

    [Price] AS [Price],

    [ProductId] AS [ProductId]

RESIDENT RestConnectorMasterTable;

View solution in original post

16 Replies
shraddha_g
Partner - Master III
Partner - Master III

Share you code

Not applicable
Author

This is the generated code. I have used getmethod and passed productid = 1 in rest connector

LIB CONNECT TO 'Rest';

RestConnectorMasterTable:

SQL SELECT 

    "CategoryName",

    "Name",

    "Price",

    "ProductId"

FROM JSON (wrap on) "root";

[root]:

LOAD    [CategoryName] AS [CategoryName],

    [Name] AS [Name],

    [Price] AS [Price],

    [ProductId] AS [ProductId]

RESIDENT RestConnectorMasterTable;

DROP TABLE RestConnectorMasterTable;

shraddha_g
Partner - Master III
Partner - Master III

http://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/1.1/Load-REST-data/Sele...

For Dynamic Parameters Refer Thread REST connector with automatic date update

You can try:

Let vProductId = 2;

RestConnectorMasterTable:

SQL SELECT 

    "CategoryName",

    "Name",

    "Price",

    "ProductId"

FROM JSON (wrap on) "root"

WITH CONNECTION ( 

QUERY "ProductId" "$(vProductId)")

;

[root]:

LOAD    [CategoryName] AS [CategoryName],

    [Name] AS [Name],

    [Price] AS [Price],

    [ProductId] AS [ProductId]

RESIDENT RestConnectorMasterTable;

Not applicable
Author

I had set query parameter value 1 bydefault in rest connector . I am getting productid 1 data. Its not filtering using vProductId = 2 . Its a get method . Will your query work on get method ?

Not applicable
Author

This is my get method

[OperationContract]

        [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/GetProductListByproductId/{*Id}")]

        List<Product> GetProductListByproductId(string Id);

shraddha_g
Partner - Master III
Partner - Master III

I haven't tried with Get Method.

But you can try some solutions from

http://help.qlik.com/en-US/connectors/Subsystems/REST_connector_help/Content/1.1/Load-REST-data/Sele...05106734-1799817335.1478168646

Try changing Url parameter.

Example is given in above link

Not applicable
Author

Now I have written one POST method.

   [OperationContract]

         [WebInvoke(Method = "POST",

         BodyStyle = WebMessageBodyStyle.Bare,

         RequestFormat = WebMessageFormat.Json,

         ResponseFormat = WebMessageFormat.Json,

         UriTemplate = "GetCategoryList/")]

         List<Product> GetCategoryList(test id);

What should I do in the request body space in the rest connector ?

shraddha_g
Partner - Master III
Partner - Master III

Does POST method works for Productid =1?

Not applicable
Author

In post man application I tested POST method with parameter {"id":"1"}. Then Its working.

Here in rest connector there is a space for request body..what should i fill in that box.