Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I am trying to develop a Job that exposes a rest end point and this end point tales in two parameters:
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.
When I execute this, I pass the two parameters
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:
Am I missing some config ?
Any Ideas
Thanks
Patrice
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...
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."
Ah I see. Thanks Richard.