Skip to content
Advertisement

Java 11: New HTTP client send POST requests with x-www-form-urlencoded parameters

I’m trying to send a POST request using the new http client api. Is there a built in way to send parameters formatted as x-www-form-urlencoded ?

My current code:

JavaScript

What I’m looking is for a better way to pass the parameters. Something like this:

JavaScript

Do I need to build myself this functionality or is something already built in?

I’m using Java 12.

Advertisement

Answer

I think the following is the best way to achieve this using Java 11:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement