# How to send a simple "GET" or "POST" with parameters

**URL:** https://discourse.julialang.org/t/how-to-send-a-simple-get-or-post-with-parameters/54125
**Category:** Web Stack
**Created:** [January 28, 2021, 2:33pm UTC](https://discourse.julialang.org/t/how-to-send-a-simple-get-or-post-with-parameters/54125 "2021-01-28T14:33:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nuclear718](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nuclear718/32/16163_2.png) [@nuclear718](https://discourse.julialang.org/u/nuclear718)
#### Post date: [January 28, 2021, 2:33pm UTC](https://discourse.julialang.org/t/how-to-send-a-simple-get-or-post-with-parameters/54125/1 "2021-01-28T14:33:24Z")

</div>

The data provider has an example in python:

```python
url = "xxx"
parameter = {
    "dataset": "TaiwanStockInfo",
    "token": "", # 參考登入，獲取金鑰
}
resp = requests.get(url, params=parameter)

```

**How to translate these simple python code into Julia language?**  
I try many times but fail…below is my fail example:

```julia
url="xxx"
parameter = Dict("dataset" => "TaiwanVariousIndicators5Seconds",
        "start_date" => "2020-07-01",
        "end_date" => "2020-07-27",
        "token" => "xxx")
pms=JSON.json(parameter)
r=HTTP.request("GET", url,["Content-Type" => "application/json"],pms)

```

or

```julia
url="xxx"
parameter = Dict("dataset" => "TaiwanVariousIndicators5Seconds",
        "start_date" => "2020-07-01",
        "end_date" => "2020-07-27",
        "token" => "xxx")
r=HTTP.request("GET", url,["Content-Type" => "application/json"],parameter)

```

```julia
parameter = ["dataset"=> "TaiwanStockInfo",
        "token" => "xxx"]
HTTP.request("GET", url,
             ["Content-Type" => "application/json"],
             parameter)

```

All above code are fail and return error message like this:  
“HTTP.ExceptionRequest.StatusError(422, “GET”, “/api/v4/data”, HTTP.Messages.Response:”

---

<div class="post-metadata">

### Author: ![pixel27](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pixel27/32/8902_2.png) [@pixel27](https://discourse.julialang.org/u/pixel27)
#### Post date: [January 28, 2021, 3:30pm UTC](https://discourse.julialang.org/t/how-to-send-a-simple-get-or-post-with-parameters/54125/2 "2021-01-28T15:30:33Z")

</div>

Probably the easiest way would be:

```julia
using URIs

uri = URI("https://www.google.com/search")
uri = URI(uri; query=Dict("q" => "julia"))

HTTP.request("GET", string(uri))

```

The first `URI()` defines the bulk of the URL. The second `URI()` adds the query string (parameters) to the URL. Then you convert it to a string, URI will URL encode the query string for you, and pass it to `HTTP.request()`.

---

<div class="post-metadata">

### Author: ![nuclear718](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nuclear718/32/16163_2.png) [@nuclear718](https://discourse.julialang.org/u/nuclear718)
#### Post date: [January 31, 2021, 2:41am UTC](https://discourse.julialang.org/t/how-to-send-a-simple-get-or-post-with-parameters/54125/3 "2021-01-31T02:41:14Z")

</div>

Your suggestion is work! Thanks.
