You can use something like: Replacing Http-Connector with Jsoup usage
or whatever your flavour of client is, and use the Nashorn JS Java interop to access the java libs for HTTP
The Forum is FULL of JS code examples and how to use nashorn for various complex and simple use cases. (mostly posted by myself over the years), so would recommend some searching around the forum for Nashorn examples.