How can I get the request URI from the request of an HTTP Listener?

0 votes
asked Apr 30 by rich-c-2789 (17,430 points)
edited Apr 30 by rich-c-2789
I have an HTTP Listener source node configured to process HTTP requests. Some requests need to be routed down a different node path for processing.

For example:

I want requests like this "http://host/something/labs" to be split off from the main node path using a condition node.  Separate mapping nodes will process the rest of these requests.

How can I access the request URI so I can use it?

1 Answer

0 votes

Yes, you can access the request URI if the "Extract content as message (discard HTTP Headers and other MetaData)" is not checked on the "HTTP Configuration" tab of the "HTTP Listener". When it is not checked, you can access request metadata within your mapping and condition scripts and from a "Standard" condition node, etc.

To access the request URI within your mapping scripts use the following code:

var requestURI = source.getNode('/Request/RequestURI');

In the above code, if the request was "http://host/something/labs" the requestURI variable would be set to "/something/labs".

From a "Standard" condition node see this screenshot.

In the above image the "Source" field is set to "Source Node". To access the request URI the "Node Path" is set to "/Request/RequestURI". The rest fields can be set based on your needs. The resulting code in the condition node looks like this:

var value = source.getNode('/Request/RequestURI');
return !StringUtils.equalsIgnoreCase(value, '/something/labs');


See also:

Handling HTTP requests and responses

Processing Requests in mapping nodes via HTTP Listener source node

answered Apr 30 by rich-c-2789 (17,430 points)
edited May 16 by rich-c-2789