HTTP.request("POST"...) seems to be using "GET" instead

Hi,

I’m having an issue with a POST request using HTTP.jl where it seems to be doing a GET request instead.

Versions:

  • Julia 1.9.0
  • HTTP.jl 1.7.3

Code:

import HTTP
response = HTTP.request("POST", "http://fiaweather.mfsports.fr/api/verify"; body="""{"token":"test"}""", verbose=3)

Expected result is along the lines of (can see here: https://reqbin.com/hcadtmua) :

HTTP/1.1 400 Bad Request
server: nginx
date: Mon, 10 Jul 2023 21:12:43 GMT
content-type: application/json
content-length: 46
allow: POST, OPTIONS
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
vary: Origin
access-control-allow-origin: *

{"non_field_errors":["Error decoding token."]}

However, I get the following in Julia which seems to suggest that the method used is GET which is not allowed:

ERROR: HTTP.Exceptions.StatusError(405, "GET", "/api/verify/", HTTP.Messages.Response:
"""
HTTP/1.1 405 Method Not Allowed
server: nginx
date: Mon, 10 Jul 2023 22:30:37 GMT
content-type: application/json
content-length: 40
allow: POST, OPTIONS
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
vary: Origin
access-control-allow-origin: *

{"detail":"Method \"GET\" not allowed."}""")
Stacktrace:
  [1] (::HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}})(stream::HTTP.Streams.Stream{HTTP.Messages.Response, HTTP.ConnectionPool.Connection{MbedTLS.SSLContext}}; status_exception::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.ExceptionRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\ExceptionRequest.jl:16
  [2] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\ExceptionRequest.jl:13 [inlined]
  [3] #1#2
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\TimeoutRequest.jl:17 [inlined]
  [4] (::HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}})(req::HTTP.Messages.Request; proxy::Nothing, socket_type::Type, socket_type_tls::Type, readtimeout::Int64, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.ConnectionRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\ConnectionRequest.jl:111
  [5] (::HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}})(req::HTTP.Messages.Request; canonicalize_headers::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.CanonicalizeRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\CanonicalizeRequest.jl:17
  [6] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\CanonicalizeRequest.jl:13 [inlined]
  [7] (::Base.var"#90#92"{Base.var"#90#91#93"{ExponentialBackOff, HTTP.RetryRequest.var"#3#6"{Int64, typeof(HTTP.RetryRequest.FALSE), HTTP.Messages.Request, Base.RefValue{Int64}}, HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}})(args::HTTP.Messages.Request; kwargs::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ Base .\error.jl:296
  [8] (::HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}})(req::HTTP.Messages.Request; retry::Bool, retries::Int64, retry_delays::ExponentialBackOff, retry_check::Function, retry_non_idempotent::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.RetryRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\RetryRequest.jl:75
  [9] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\RetryRequest.jl:30 [inlined]
 [10] (::HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}})(req::HTTP.Messages.Request; cookies::Bool, cookiejar::HTTP.Cookies.CookieJar, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.CookieRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\CookieRequest.jl:42
 [11] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\CookieRequest.jl:19 [inlined]
 [12] (::HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}})(req::HTTP.Messages.Request; detect_content_type::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.ContentTypeDetection C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\ContentTypeRequest.jl:23
 [13] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\ContentTypeRequest.jl:14 [inlined]
 [14] (::HTTP.BasicAuthRequest.var"#1#3"{HTTP.BasicAuthRequest.var"#1#2#4"{HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}})(req::HTTP.Messages.Request; basicauth::Bool, kw::Base.Pairs{Symbol, Union{Nothing, Int64}, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:iofunction, :decompress, :verbose), Tuple{Nothing, Nothing, Int64}}})
    @ HTTP.BasicAuthRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\BasicAuthRequest.jl:22
 [15] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\BasicAuthRequest.jl:14 [inlined]
 [16] (::HTTP.DefaultHeadersRequest.var"#1#3"{HTTP.DefaultHeadersRequest.var"#1#2#4"{HTTP.BasicAuthRequest.var"#1#3"{HTTP.BasicAuthRequest.var"#1#2#4"{HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}}})(req::HTTP.Messages.Request; iofunction::Nothing, decompress::Nothing, kw::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:verbose,), Tuple{Int64}}})
    @ HTTP.DefaultHeadersRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\DefaultHeadersRequest.jl:47
 [17] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\DefaultHeadersRequest.jl:13 [inlined]
 [18] (::HTTP.RedirectRequest.var"#1#4"{HTTP.RedirectRequest.var"#1#2#5"{HTTP.DefaultHeadersRequest.var"#1#3"{HTTP.DefaultHeadersRequest.var"#1#2#4"{HTTP.BasicAuthRequest.var"#1#3"{HTTP.BasicAuthRequest.var"#1#2#4"{HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}}}}})(req::HTTP.Messages.Request; redirect::Bool, redirect_limit::Int64, redirect_method::Nothing, forwardheaders::Bool, response_stream::Nothing, kw::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:verbose,), Tuple{Int64}}})
    @ HTTP.RedirectRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\RedirectRequest.jl:25
 [19] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\RedirectRequest.jl:14 [inlined]
 [20] #3
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\DebugRequest.jl:20 [inlined]
 [21] (::LoggingExtras.var"#35#37"{HTTP.DebugRequest.var"#3#6"{Int64, Base.Pairs{Symbol, Nothing, Tuple{Symbol}, NamedTuple{(:response_stream,), Tuple{Nothing}}}, HTTP.Messages.Request, HTTP.RedirectRequest.var"#1#4"{HTTP.RedirectRequest.var"#1#2#5"{HTTP.DefaultHeadersRequest.var"#1#3"{HTTP.DefaultHeadersRequest.var"#1#2#4"{HTTP.BasicAuthRequest.var"#1#3"{HTTP.BasicAuthRequest.var"#1#2#4"{HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}}}}}}})()
    @ LoggingExtras C:\Users\titas\.julia\packages\LoggingExtras\5k9PW\src\verbosity.jl:103
 [22] with_logstate(f::Function, logstate::Any)
    @ Base.CoreLogging .\logging.jl:514
 [23] with_logger
    @ .\logging.jl:626 [inlined]
 [24] withlevel(f::HTTP.DebugRequest.var"#3#6"{Int64, Base.Pairs{Symbol, Nothing, Tuple{Symbol}, NamedTuple{(:response_stream,), Tuple{Nothing}}}, HTTP.Messages.Request, HTTP.RedirectRequest.var"#1#4"{HTTP.RedirectRequest.var"#1#2#5"{HTTP.DefaultHeadersRequest.var"#1#3"{HTTP.DefaultHeadersRequest.var"#1#2#4"{HTTP.BasicAuthRequest.var"#1#3"{HTTP.BasicAuthRequest.var"#1#2#4"{HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}}}}}}, level::Base.CoreLogging.LogLevel; verbosity::Int64)
    @ LoggingExtras C:\Users\titas\.julia\packages\LoggingExtras\5k9PW\src\verbosity.jl:99
 [25] withlevel
    @ C:\Users\titas\.julia\packages\LoggingExtras\5k9PW\src\verbosity.jl:98 [inlined]
 [26] #1#2
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\DebugRequest.jl:19 [inlined]
 [27] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\DebugRequest.jl:16 [inlined]
 [28] (::HTTP.MessageRequest.var"#1#3"{HTTP.MessageRequest.var"#1#2#4"{HTTP.DebugRequest.var"#1#4"{HTTP.DebugRequest.var"#1#2#5"{HTTP.RedirectRequest.var"#1#4"{HTTP.RedirectRequest.var"#1#2#5"{HTTP.DefaultHeadersRequest.var"#1#3"{HTTP.DefaultHeadersRequest.var"#1#2#4"{HTTP.BasicAuthRequest.var"#1#3"{HTTP.BasicAuthRequest.var"#1#2#4"{HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}}}}}}}}})(method::String, url::URIs.URI, headers::Nothing, body::String; copyheaders::Bool, response_stream::Nothing, http_version::HTTP.Strings.HTTPVersion, kw::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:verbose,), Tuple{Int64}}})
    @ HTTP.MessageRequest C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\MessageRequest.jl:27
 [29] #1
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\clientlayers\MessageRequest.jl:23 [inlined]
 [30] request(stack::HTTP.MessageRequest.var"#1#3"{HTTP.MessageRequest.var"#1#2#4"{HTTP.DebugRequest.var"#1#4"{HTTP.DebugRequest.var"#1#2#5"{HTTP.RedirectRequest.var"#1#4"{HTTP.RedirectRequest.var"#1#2#5"{HTTP.DefaultHeadersRequest.var"#1#3"{HTTP.DefaultHeadersRequest.var"#1#2#4"{HTTP.BasicAuthRequest.var"#1#3"{HTTP.BasicAuthRequest.var"#1#2#4"{HTTP.ContentTypeDetection.var"#1#3"{HTTP.ContentTypeDetection.var"#1#2#4"{HTTP.CookieRequest.var"#1#5"{HTTP.CookieRequest.var"#1#2#6"{HTTP.RetryRequest.var"#1#4"{HTTP.RetryRequest.var"#1#2#5"{HTTP.CanonicalizeRequest.var"#1#3"{HTTP.CanonicalizeRequest.var"#1#2#4"{HTTP.ConnectionRequest.var"#1#7"{HTTP.ConnectionRequest.var"#1#2#8"{HTTP.TimeoutRequest.var"#1#6"{HTTP.TimeoutRequest.var"#1#2#7"{HTTP.ExceptionRequest.var"#1#3"{HTTP.ExceptionRequest.var"#1#2#4"{typeof(HTTP.StreamRequest.streamlayer)}}}}}}}}}}}}}}}}}}}}}}}}, method::String, url::String, h::Nothing, b::String, q::Nothing; headers::Nothing, body::String, query::Nothing, kw::Base.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:verbose,), Tuple{Int64}}})
    @ HTTP C:\Users\titas\.julia\packages\HTTP\RxlHW\src\HTTP.jl:426
 [31] #request#17
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\HTTP.jl:286 [inlined]
 [32] request
    @ C:\Users\titas\.julia\packages\HTTP\RxlHW\src\HTTP.jl:284 [inlined]
 [33] top-level scope
    @ REPL[2]:1

As a separate note, this works in MATLAB and gives the correct response (only mentioning as that’s where I am porting it from):

>> webwrite("http://fiaweather.mfsports.fr/api/verify/", struct('token', 'test'), weboptions('RequestMethod', 'post'))
Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray
The server returned the status 400 with message "Bad Request" in response to the request to URL https://fiaweather.mfsports.fr/api/verify/.

Error in readContentFromWebService (line 46)
        byteArray = copyContentToByteArray(connection);

Error in webwrite (line 139)
    [varargout{1:nargout}] = readContentFromWebService(connection, options);

Also, I get the same error (405) in Julia when using an actual token, while in MATLAB I get a correct success response.

Any help or suggestions are highly appreciated!

Just did a fast Postman test, and here is the result:

Now, we only need to discover what “implicit” parameter we are missing.

Later edit:
The “GET” is request is caused by the HTTP.jl/Postman following the 302 redirect code issued by the server (302 implies a GET). Please see the following post for details and solution.

The issue seems to be related to the wrong redirect code used by the server.

The server issues a 302 redirect (which implies a GET, not a POST).

Both HTTP.jl and Postman follow this rule and assume a GET (but the server plays by different rules).

So, the solution is to set the redirect method in the HTTP.jl request explicitly:

import HTTP
body = Dict("token" => "test")
url = "http://fiaweather.mfsports.fr/api/verify"
response = HTTP.request("POST", url; body=body, redirect_method="POST")
3 Likes

Thanks @algunion, that works!

For future reference, how do you check if this type of thing is happening?

One option is to disable the redirect altogether:

import HTTP
body = Dict("token" => "test")
url = "http://fiaweather.mfsports.fr/api/verify"
response = HTTP.request("POST", url; body=body, redirect=false)

If you execute the above, you’ll get the following response:

HTTP.Messages.Response:
"""
HTTP/1.1 302 Moved Temporarily
content-length: 0
location: https://fiaweather.mfsports.fr/api/verify
cache-control: no-cache
connection: close

"""

But you might ask how I knew it was something related to redirect in the first place. The answer is Stacktrace:... From stacktrace, it was clear that we had a POST followed by a redirect - after that, it was easy just to disable the redirect and see which redirect code was used.

Not sure if this is “the way” - but it worked for me. Maybe @quinnj can point out the best practice for this kind of stuff.

1 Like