Escape values for application/x-www-form-urlencoded requests

I'm using the HTTP client to make a POST request with application/x-www-form-urlencoded, but I get an error because a variable seemingly contains an invalid character:

POST http://localhost:8080/auth/realms/REDACTED/protocol/openid-connect/token
Content-Type: application/x-www-form-urlencoded

client_id = REDACTED &
grant_type = password &
username = {{username}} &
password = {{password}}


URLDecoder: Illegal hex characters in escape (%) pattern - Error at index 0 in: "Z5"

Indeed, password has a % character:

"password": "j%Z5P(DVJ?;{2%B\\F..."

I've figured out that I can add a new variable to the env file with the URL-encoded password:

"urlEncodedPassword": "j%25Z5P%28DVJ%3F%3B%7B2%25B%5..."

That works but, is there a better way? Is there a function or syntax to escape when reading the variable in the *.http file?


Please sign in to leave a comment.