How to access HTTP params in script node

GET | api/books/{isbn}
to create this api ,

logging the bh.input from script node gives,

I am giving isbn as params.

it works in query :

How can I access params ?. Is there any way to directly add isbn to the url in here :

Hi @JeevanKumar , if you want to read params value, use bh.input.params / query/body based on what you configured in your Http IN Node. For example here:

based on what type you used you will get the value in bh.input object.
And if you want to use that value and call an api, Please find the below sample code:

bh.local.openLibraryUrl = ${yourBaseUrl}/${bh.input.query.isbn};

and now use bh.local.openLibraryUrl as url in HTTP request node and you will call the get api with the desired input value.

1 Like

Thank you @Hariharan_J
But That I Checked,
when I change to query, it works properly and in script node I am able access it. but when selecting path as type in HTTP in, api call from postman is not even reaches the server,
http://localhost:8081/api/books/sdlfas


But same end point is working when calling form swagger :

it enters the server and logs the bh.input from script node.
:nerd_face: removed all same path routes to avoid conflict with method but still path is not working

Hi @JeevanKumar,

To specify the path properly in the endpoint try /books/:isbn .
Please see the attached screenshot for better reference and the is a link below that could help you.
Then you should be able to the see the params on your logs.



HTTP In node

1 Like

Thank you @Simphiwe it worked.
I need help to understand this :
Adding parameters in HTTP In node is only for swagger documentation.

because without api…/:id we can test the api from swagger (by only giving parameter type path).

Hi @JeevanKumar,

So, adding parameters on studio it is required for that input field for params/path to show since you can’t add your value params on your URL in swagger UI like /12 if your variable parts of a URL path is /:id.
And adding /:id makes your url to expect paths even if you not using swagger UI.

1 Like