Sidebar

How can I get the query string parameters from a request to an HTTP Listener?

0 votes
67 views
asked Apr 30 by rich-c-2789 (17,430 points)
I have an HTTP Listener source node configured to process HTTP requests. I want some data passed in the query string to be used to describe the patient record passed in the content.

For example:

I want requests like this

"http://host/something/labs?fileName=patient101record.pdf&createdDate=04302024&lastModifiedDate=04302024"

to be used to simplify processing of the uploaded file bytes in the content.

How can I access the query string?

1 Answer

0 votes
 
Best answer

Yes, you can access a requests query string 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 query string within your mapping scripts use the following code:

var queryString = source.getNode('/Request/QueryString');

In the above code, if the request was:

"http://host/something/labs?fileName=patient101record.pdf&createdDate=04302024&lastModifiedDate=04302024"

the queryString variable would be set to:

"fileName=patient101record.pdf&createdDate=04302024&lastModifiedDate=04302024" 

To parse out and access the individual values by name from the queryString see the published function provided in this KB:

How to extract the Query Parameters from HTTP call? - Knowledge Base - Qvera

To URL decode values see this KB:

How do I unescape %40 from a queryString?

See also:

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

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
...