HTTP POST xml request with headers and authentification

You can compare the requests using netcat, e.g.

$ netcat -lp 8080

and send the requests to http://localhost:8080. That should give you an idea what the difference is.


This looks wrong though, the headers in the second argument should be an array of pairs, i.e.

["Content-Type" => "application/xml", "userpwd" => "myname:mypassword"]

However, do you really want to set a header called userpwd to that string? I would guess this uses HTTP basic authentication and you should instead include it in the URL,

HTTP.post("https://myname:mypassword@mywebsite.net", ...)

which HTTP.jl will rewrite to an Authorization header after encoding it, e.g.

HTTP.get("http://user:pass@localhost:8080")

gives

$ netcat -lp 8080
GET / HTTP/1.1
Authorization: Basic dXNlcjpwYXNz
Host: localhost:8080
Accept: */*
User-Agent: HTTP.jl/1.6.1
Content-Length: 0

Alternatively you can set the header yourself, e.g.

using HTTP, Base64
HTTP.get("http://localhost:8080", ["Authorization" => "Basic $(base64encode("user:pass"))")
2 Likes