Form encoded data

How can I reproduce this python code with HTTP.jl?

url = 'https://myurl.com/api'
params = {'par': val}
headers = {'Content-Type': 'application/x-www-form-urlencoded'}
with open(filename, 'rb') as f:
    r = requests.post(url, headers=headers, params=params, data={'file': f.read()})

What I have

uri = HTTP.URI(;
    scheme = "https",
    host = "myurl.com",
    path = "/api",
    query = Dict("par" => val))

r= open(filename) do file
    HTTP.post(
        uri, 
        ["Content-Type" => "application/x-www-form-urlencoded"],
        HTTP.Form(Dict("file" => read(file, String))))
end

But unfortunately it does not work.

1 Like