Question on HTTP.jl

Hi, I’m trying to do a lookup on IP addresses using HTTP.jl [cd3eb016] HTTP v0.9.5, I purposely put in invalid addresses to see how it responds, and not sure how to access this error:

The request is:

ipaddr = ""
response = HTTP.get("$endpoint?apiKey=$apikey&ip=$ipaddr&lang=$language&include=security")

the response, slightly anonymized, is:

ERROR: HTTP.ExceptionRequest.StatusError(423, "GET", "/ipgeo?apiKey=1111&ip=", HTTP.Messages.Response:
HTTP/1.1 423 Locked
Date: Thu, 11 Mar 2021 01:57:23 GMT
Content-Type: application/json;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
{"message":"'' is a bogon (Private network) IP address."}""")

response is nil so I can’t seem to access response.status nor response.body

I was expecting response.status to be 423 and the response.body to be {"message":"'' is a bogon (Private network) IP address."}

To be clear, I want access to the status and the “message” included in the error.

What am I missing or doing wrong?


The body is:

{"message":"'' is a bogon (Private network) IP address."}

And the status code is 423 Locked as you can see in the error, just like you expect.
you probably did:

response = HTTP.get(...) # throws
response == nothing  # Nani !?

You can’t expect a return value when a function throws an exception.
Use: HTTP.get(...; status_exception=false) to not throw.


Thank you. I somehow missed that setting in HTTP.request docstrings.