Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
swetha54
Contributor III
Contributor III

passing variables to APIs in Qliksense

Hi All,

We have created a variable for account number called vAccountno and passed that to fetch account level info from an API and that info has Order number as well. 

Now we need to pass the one of the order numbers from the above list of orders of vAccountno to a new API to fetch Order line item details.

Can any one please suggest the possible solution for this.

5 Replies
andoryuu
Creator III
Creator III

We've accomplished this with REST API calls by using CUSTOM CONNECT TO to invoke the REST API instead of a dedicated connection object.   Please note you have to switch your engines over to legacy mode to do this.  You then pass the variable into the statement with expansion like the below.  You'll see that i have variables in my statement for password, userid, and security method as well.

for i=1 to NoOfRows('RestConnectorMasterTable') //change this to the table that contains your account numbers - if you only have one you don't have to do this step

let vAccountno=FieldValue('AccountNumber',$(i));

CUSTOM CONNECT TO "provider=QvRestConnector.exe;url=http://YourRestAPIEndpoint/orders/accountno=$(vAccountno)?onlyActive=true;timeout=$(vTimeout);method=GET;autoDetectResponseType=true;keyGenerationStrategy=0;authSchema=$(vSecurityMethod);skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=LocalMachine;certificateStoreName=My;addMissingQueryParametersToFinalRequest=false;PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;UserId=$(vAcct);Password=$(vPW)";

NEXT

 

swetha54
Contributor III
Contributor III
Author

Thanks for your suggestion!

We wanted to have the order number selected from the dropdown from app to be passed to the load script editor .

We have code already in place to pass the received order number to the API.We are using POST method .

Please let me know if there is a way where dropdown field selection value could be obtained in the load script.

 

Thanks,

Swetha

andoryuu
Creator III
Creator III

Yes, we have done this by using the reload button extension, used variables to hold drop down selections, and used if() statements in our data load script to detect the set variable values to know to skip the dataload and instead execute a stored procedure that encapsulates the process we are invoking.  We've also gotten quite creative with ODAG using passed values, REST APIs, and stored procedures.

swetha54
Contributor III
Contributor III
Author

Thanks alot for your response.

Could you please provide sample qvf file for the same.

 

andoryuu
Creator III
Creator III

I'm forbidden from sharing any company intellectual property on forums, but if you follow my suggestions above through experimentation along with the guidance on using ODAG here you can accomplish this goal using my solution above.