# HTTP post usage

**URL:** <https://discourse.julialang.org/t/http-post-usage/74014>\
**Category:** New to Julia\
**Tags:** http\
**Created:** [January 4, 2022, 2:41am UTC](https://discourse.julialang.org/t/http-post-usage/74014 "2022-01-04T02:41:06Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![paulmelis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paulmelis/32/35063_2.png) [@paulmelis](https://discourse.julialang.org/u/paulmelis)\
**Post date:** [January 5, 2022, 8:49am UTC](https://discourse.julialang.org/t/http-post-usage/74014/6 "2022-01-05T08:49:53Z")

</div>

> [@sransome](#):
>
> if I’m to use a string for a body with multiple parameters what should that look like?

Looking at the analogous API in Python’s `requests` module (which does take a dict), those values are encoded as content-type `application/x-www-form-urlencoded`:

```julia
import requests
r=requests.post('http://localhost:8080/', data={'a':1, 'b': "doh"})

melis@juggle 09:37:~$ nc -l -p 8080
POST / HTTP/1.1
Host: localhost:8080
User-Agent: python-requests/2.26.0
Accept-Encoding: gzip, deflate, br
Accept: */*
Connection: keep-alive
Content-Length: 9
Content-Type: application/x-www-form-urlencoded

a=1&b=doh

```

So if you can do the same with HTTP.jl that should work. [Here’s](https://discourse.julialang.org/t/form-encoded-data/31869) actually a post on this forum from some years ago, with exactly the same issue, but no answer :-(. There’s actually also a closed HTTP.jl [issue](https://github.com/JuliaWeb/HTTP.jl/issues/281) to document exactly the thing you want here, but the docs were only updated for the case of POSTing JSON, although the issue does give a solution (see [this comment](https://github.com/JuliaWeb/HTTP.jl/issues/281#issuecomment-414177317)):

```julia
headers = ["Content-Type" => "application/x-www-form-urlencoded"]
params = Dict("Password" => "password")
body = HTTP.URIs.escapeuri(params)
response = HTTP.post("http://localhost:8080", headers, body, verbose=2)
HTTP.Messages.Request:
"""
POST / HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Host: localhost:8080
Accept: */*
User-Agent: HTTP.jl/1.7.1
Content-Length: 17

Password=password"""

```

Edit: deleted reference to example that does not apply here

---

_[View the full topic](https://discourse.julialang.org/t/http-post-usage/74014)._
