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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Passing Parameters to RESTRequest

Hello

 

I am trying to develop a Job that exposes a rest end point and this end point tales in two parameters:

  1. areaCode
  2. groupNumber

I want to use these parameters later on in the flow to restrict a SQL Statement.

 

I have defined a 'tRESTrequest' and have added a API Mapping with a URI Pattern of "/{areaCode}/{groupNumber}/". In the Output Flow I have defined the two parameters.

 

 

0683p000009LxgR.png

0683p000009LxgH.png

When I execute this, I pass the two parameters

 

0683p000009LxKG.png

 

However the two parameters are evaluated to null. I have put a Java component to debug the the Request Object and it confirms that they are null.

 

The tJavaRow Component code is:

 

System.out.println("Area Code   : "+globalMap.get("groupCode.areaCode"));
System.out.println("Group Number: "+globalMap.get("groupCode.groupNumber"));

//The object with the key "restRequest" is a HashMap
java.util.Map<String, Object> myMap = ((java.util.Map<String, Object>)globalMap.get("restRequest"));

//Print out of what you are seeing already
System.out.println("MyMap = " +myMap.toString());

//Create an iterator over the keyset
java.util.Iterator<String> it = myMap.keySet().iterator();

//Iterate over the keyset and print out the keys
while(it.hasNext()){
	System.out.println(it.next());
}

//Retrieve the PARAMS HashMap
java.util.Map<String, Object> myParams = ((java.util.Map<String, Object>)myMap.get("PARAMS"));

//Create an Iterator for the PARAMS HashMap
java.util.Iterator<String> it2 = myParams.keySet().iterator();

//Iterate over the PARAMS HasMap
while(it2.hasNext()){
	System.out.println(it2.next());
}

The output is:

0683p000009LxYX.png

 

Am I missing some config ?

 

Any Ideas

 

Thanks

 

Patrice

Labels (4)
12 Replies
Anonymous
Not applicable
Author

Okay I think I resolved it, when referencing REST Inbound parameters, you do NOT need to use the 'globalMap.get'.

 

You just refer directly...

 

FROM WalkDetails "+
"WHERE WalkDetails.Group_Code = '"+groupCode.areaCode+groupCode.groupNumber+"'"

 

This worked...

 

Anyway...I have another question.

 

I want to add a check after the SQL Query and count number of rows returned, if 0 then I want the REST Response to return a custom message saying "Now rows found etc"

 

Is this possible...

Anonymous
Not applicable
Author

That is pretty much what I was trying to say with......"The AreaCode and GroupNumber are not stored in the globalMap. They are columns in the row from your tRESTRequest component."

Anonymous
Not applicable
Author

Ah I see. Thanks Richard.