Authorize REST request if @ is in username

Using post function from package Requests I have to authorize the communication.
I follow recommendation in Requests.jl

post(“http://username:password@httpbin.org/post”)

However I have to use username in the form of e-mail address.

post( “https://test@test.com:passwd@httpbin.org/post”)

Then I get response

Port must be numeric (decimal)

Can you advise how to authorize username in form of an e-mail address, please ?

Because the username/password are in the “host” part of the url, they need to be URL-encoded (since the set of allowed characters for hosts is extremely restricted). So the following works for me:

HTTP.post("https://" * HTTP.escape("test@test.com:passwd") * "@httpbin.org")

That’s perhaps something a package like HTTP.jl could detect automatically though, so I created an issue to look into it.

2 Likes

quimmj kindly thank you for the answer.