# Help making HTTP.request for Manifold

**URL:** <https://discourse.julialang.org/t/help-making-http-request-for-manifold/133069>\
**Category:** General Usage\
**Tags:** question, http\
**Created:** [October 11, 2025, 12:54pm UTC](https://discourse.julialang.org/t/help-making-http-request-for-manifold/133069 "2025-10-11T12:54:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 11, 2025, 12:54pm UTC](https://discourse.julialang.org/t/help-making-http-request-for-manifold/133069/1 "2025-10-11T12:54:04Z")

</div>

Hello. I am trying to submit a request to Manifold.markets via HTTP.jl, but I am having trouble with the setup. The API description is posted [here](https://docs.manifold.markets/api#post-v0bet). Here is one thing I tried.

**Code**

```julia
using HTTP

header = Dict(
    "Authorization" => "authorization_code_here",
    "Content-Type" => "application/json"
)

body = Dict(
    "contractId" => "9t61v9e7x4",
    "amount" => 10,
    "outcome" => "Yes",
    "dryRun" => true
)

url = "https://api.manifold.markets/v0/bet"

resp = HTTP.request("POST", url, header, body)

```

**Error**

> **Summary**
>
> ```julia
> ERROR: HTTP.Exceptions.StatusError(500, "POST", "/v0/bet", HTTP.Messages.Response:
> """
> HTTP/1.1 500 Internal Server Error
> x-powered-by: Express
> content-type: application/json; charset=utf-8
> Content-Length: 892
> etag: W/"37c-stTRymLa8xFAQm8E6eF5FQcHHUs"
> vary: Accept-Encoding
> date: Sat, 11 Oct 2025 12:50:20 GMT
> via: 1.1 google
> Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
> 
> {"message":"SyntaxError: Unexpected token 'a', \"#\" is not valid JSON\n at JSON.parse (<anonymous>)\n at createStrictSyntaxError (/usr/src/app/node_modules/body-parser/lib/types/json.js:160:10)\n at parse (/usr/src/app/node_modules/body-parser/lib/types/json.js:83:15)\n at /usr/src/app/node_modules/body-parser/lib/read.js:128:18\n at AsyncResource.runInAsyncScope (node:async_hooks:206:9)\n at invokeCallback (/usr/src/app/node_modules/raw-body/index.js:231:16)\n at done (/usr/src/app/node_modules/raw-body/index.js:220:7)\n at IncomingMessage.onEnd (/usr/src/app/node_modules/raw-body/index.js:280:7)\n at IncomingMessage.emit (node:events:524:28)\n at endReadableNT (node:internal/streams/readable:1698:12)","error":{"expose":true,"statusCode":400,"status":400,"body":"amount=10&outcome=Yes&dryRun=true&contractId=9t61v9e7x4","type":"entity.parse.failed"}}""")
> Stacktrace:
> [1] (::HTTP.ConnectionRequest.var"#connections#connectionlayer##0"{…})(req::HTTP.Messages.Request; proxy::Nothing, socket_type::Type, socket_type_tls::Nothing, readtimeout::Int64, connect_timeout::Int64, logerrors::Bool, logtag::Nothing, closeimmediately::Bool, kw::@Kwargs{…})
> @ HTTP.ConnectionRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/ConnectionRequest.jl:144
> [2] connections
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/ConnectionRequest.jl:60 [inlined]
> [3] (::Base.var"#46#47"{…})(args::HTTP.Messages.Request; kwargs::@Kwargs{…})
> @ Base ./error.jl:309
> [4] (::HTTP.RetryRequest.var"#manageretries#retrylayer##0"{…})(req::HTTP.Messages.Request; retry::Bool, retries::Int64, retry_delays::ExponentialBackOff, retry_check::Function, retry_non_idempotent::Bool, kw::@Kwargs{…})
> @ HTTP.RetryRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RetryRequest.jl:75
> [5] manageretries
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RetryRequest.jl:30 [inlined]
> [6] (::HTTP.CookieRequest.var"#managecookies#cookielayer##0"{…})(req::HTTP.Messages.Request; cookies::Bool, cookiejar::HTTP.Cookies.CookieJar, kw::@Kwargs{…})
> @ HTTP.CookieRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/CookieRequest.jl:42
> [7] managecookies
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/CookieRequest.jl:19 [inlined]
> [8] (::HTTP.HeadersRequest.var"#defaultheaders#headerslayer##0"{…})(req::HTTP.Messages.Request; iofunction::Nothing, decompress::Nothing, basicauth::Bool, detect_content_type::Bool, canonicalize_headers::Bool, kw::@Kwargs{…})
> @ HTTP.HeadersRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/HeadersRequest.jl:71
> [9] defaultheaders
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/HeadersRequest.jl:14 [inlined]
> [10] (::HTTP.RedirectRequest.var"#redirects#redirectlayer##0"{…})(req::HTTP.Messages.Request; redirect::Bool, redirect_limit::Int64, redirect_method::Nothing, forwardheaders::Bool, response_stream::Nothing, kw::@Kwargs{…})
> @ HTTP.RedirectRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RedirectRequest.jl:25
> [11] redirects
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RedirectRequest.jl:14 [inlined]
> [12] (::HTTP.MessageRequest.var"#makerequest#messagelayer##0"{…})(method::String, url::URIs.URI, headers::Dict{…}, body::Dict{…}; copyheaders::Bool, response_stream::Nothing, http_version::HTTP.Strings.HTTPVersion, verbose::Int64, kw::@Kwargs{})
> @ HTTP.MessageRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/MessageRequest.jl:35
> [13] makerequest
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/MessageRequest.jl:24 [inlined]
> [14] request(stack::HTTP.MessageRequest.var"#makerequest#messagelayer##0"{…}, method::String, url::String, h::Dict{…}, b::Dict{…}, q::Nothing; headers::Dict{…}, body::Dict{…}, query::Nothing, kw::@Kwargs{})
> @ HTTP ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:457
> [15] request(stack::Function, method::String, url::String, h::Dict{String, String}, b::Dict{String, Any}, q::Nothing)
> @ HTTP ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:455
> [16] #request#21
> @ ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:315 [inlined]
> [17] request(method::String, url::String, h::Dict{String, String}, b::Dict{String, Any})
> @ HTTP ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:313
> [18] top-level scope
> @ ~/.julia/dev/sandbox/manifoldmarkets/temp.jl:43
> 
> caused by: HTTP.Exceptions.StatusError(500, "POST", "/v0/bet", HTTP.Messages.Response:
> """
> HTTP/1.1 500 Internal Server Error
> x-powered-by: Express
> content-type: application/json; charset=utf-8
> Content-Length: 892
> etag: W/"37c-stTRymLa8xFAQm8E6eF5FQcHHUs"
> vary: Accept-Encoding
> date: Sat, 11 Oct 2025 12:50:20 GMT
> via: 1.1 google
> Alt-Svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
> 
> {"message":"SyntaxError: Unexpected token 'a', \"#\" is not valid JSON\n at JSON.parse (<anonymous>)\n at createStrictSyntaxError (/usr/src/app/node_modules/body-parser/lib/types/json.js:160:10)\n at parse (/usr/src/app/node_modules/body-parser/lib/types/json.js:83:15)\n at /usr/src/app/node_modules/body-parser/lib/read.js:128:18\n at AsyncResource.runInAsyncScope (node:async_hooks:206:9)\n at invokeCallback (/usr/src/app/node_modules/raw-body/index.js:231:16)\n at done (/usr/src/app/node_modules/raw-body/index.js:220:7)\n at IncomingMessage.onEnd (/usr/src/app/node_modules/raw-body/index.js:280:7)\n at IncomingMessage.emit (node:events:524:28)\n at endReadableNT (node:internal/streams/readable:1698:12)","error":{"expose":true,"statusCode":400,"status":400,"body":"amount=10&outcome=Yes&dryRun=true&contractId=9t61v9e7x4","type":"entity.parse.failed"}}""")
> Stacktrace:
> [1] (::HTTP.ExceptionRequest.var"#exceptions#exceptionlayer##0"{…})(stream::HTTP.Streams.Stream{…}; status_exception::Bool, timedout::Nothing, logerrors::Bool, logtag::Nothing, kw::@Kwargs{…})
> @ HTTP.ExceptionRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/ExceptionRequest.jl:19
> [2] exceptions
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/ExceptionRequest.jl:13 [inlined]
> [3] (::HTTP.TimeoutRequest.var"#timeouts#timeoutlayer##0"{…})(stream::HTTP.Streams.Stream{…}; readtimeout::Int64, logerrors::Bool, logtag::Nothing, kw::@Kwargs{…})
> @ HTTP.TimeoutRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/TimeoutRequest.jl:18
> [4] (::HTTP.ConnectionRequest.var"#connections#connectionlayer##0"{…})(req::HTTP.Messages.Request; proxy::Nothing, socket_type::Type, socket_type_tls::Nothing, readtimeout::Int64, connect_timeout::Int64, logerrors::Bool, logtag::Nothing, closeimmediately::Bool, kw::@Kwargs{…})
> @ HTTP.ConnectionRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/ConnectionRequest.jl:122
> [5] connections
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/ConnectionRequest.jl:60 [inlined]
> [6] (::Base.var"#46#47"{…})(args::HTTP.Messages.Request; kwargs::@Kwargs{…})
> @ Base ./error.jl:309
> [7] (::HTTP.RetryRequest.var"#manageretries#retrylayer##0"{…})(req::HTTP.Messages.Request; retry::Bool, retries::Int64, retry_delays::ExponentialBackOff, retry_check::Function, retry_non_idempotent::Bool, kw::@Kwargs{…})
> @ HTTP.RetryRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RetryRequest.jl:75
> [8] manageretries
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RetryRequest.jl:30 [inlined]
> [9] (::HTTP.CookieRequest.var"#managecookies#cookielayer##0"{…})(req::HTTP.Messages.Request; cookies::Bool, cookiejar::HTTP.Cookies.CookieJar, kw::@Kwargs{…})
> @ HTTP.CookieRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/CookieRequest.jl:42
> [10] managecookies
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/CookieRequest.jl:19 [inlined]
> [11] (::HTTP.HeadersRequest.var"#defaultheaders#headerslayer##0"{…})(req::HTTP.Messages.Request; iofunction::Nothing, decompress::Nothing, basicauth::Bool, detect_content_type::Bool, canonicalize_headers::Bool, kw::@Kwargs{…})
> @ HTTP.HeadersRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/HeadersRequest.jl:71
> [12] defaultheaders
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/HeadersRequest.jl:14 [inlined]
> [13] (::HTTP.RedirectRequest.var"#redirects#redirectlayer##0"{…})(req::HTTP.Messages.Request; redirect::Bool, redirect_limit::Int64, redirect_method::Nothing, forwardheaders::Bool, response_stream::Nothing, kw::@Kwargs{…})
> @ HTTP.RedirectRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RedirectRequest.jl:25
> [14] redirects
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/RedirectRequest.jl:14 [inlined]
> [15] (::HTTP.MessageRequest.var"#makerequest#messagelayer##0"{…})(method::String, url::URIs.URI, headers::Dict{…}, body::Dict{…}; copyheaders::Bool, response_stream::Nothing, http_version::HTTP.Strings.HTTPVersion, verbose::Int64, kw::@Kwargs{})
> @ HTTP.MessageRequest ~/.julia/packages/HTTP/ShTJs/src/clientlayers/MessageRequest.jl:35
> [16] makerequest
> @ ~/.julia/packages/HTTP/ShTJs/src/clientlayers/MessageRequest.jl:24 [inlined]
> [17] request(stack::HTTP.MessageRequest.var"#makerequest#messagelayer##0"{…}, method::String, url::String, h::Dict{…}, b::Dict{…}, q::Nothing; headers::Dict{…}, body::Dict{…}, query::Nothing, kw::@Kwargs{})
> @ HTTP ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:457
> [18] request(stack::Function, method::String, url::String, h::Dict{String, String}, b::Dict{String, Any}, q::Nothing)
> @ HTTP ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:455
> [19] #request#21
> @ ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:315 [inlined]
> [20] request(method::String, url::String, h::Dict{String, String}, b::Dict{String, Any})
> @ HTTP ~/.julia/packages/HTTP/ShTJs/src/HTTP.jl:313
> [21] top-level scope
> @ ~/.julia/dev/sandbox/manifoldmarkets/temp.jl:43
> Some type information was truncated. Use `show(err)` to see complete types.
> 
> ```

I tried coverting `header` and `body` to JSON via JSON3.jl, but that didn’t work either.

Any help would be appreciated.

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [October 11, 2025, 2:15pm UTC](https://discourse.julialang.org/t/help-making-http-request-for-manifold/133069/2 "2025-10-11T14:15:49Z")

</div>

Have you tried just JSON encoding the body? From the error message and [Client · HTTP.jl](https://juliaweb.github.io/HTTP.jl/stable/client/#Body) that sounds like it would do it.

---

<div class="post-metadata">

**Author:** ![Christopher\_Fisher](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christopher_fisher/32/26132_2.png) [@Christopher\_Fisher](https://discourse.julialang.org/u/Christopher_Fisher)\
**Post date:** [October 11, 2025, 2:30pm UTC](https://discourse.julialang.org/t/help-making-http-request-for-manifold/133069/3 "2025-10-11T14:30:08Z")

</div>

Thank you. That solved the first problem. After fixing that, the error messages were more informative. I had to add “Key” to the authorization value and use all caps for “outcome =\> YES”. The following example will work while the market is open:

```julia
using HTTP
using JSON3

header = Dict(
    "Authorization" => "Key authorization_key_here",
    "Content-Type" => "application/json"
)

body = Dict(
    "contractId" => "HtsxyBopv0MSywM0f0Yp",
    "amount" => 10,
    "outcome" => "YES",
    "dryRun" => true
)

url = "https://api.manifold.markets/v0/bet"

resp = HTTP.request("POST", url, header, JSON3.write(body))

```
