How can I execute a GET with Haskell's Network.HTTP.Req library?

Viewed 416

I am trying to execute a simple HTTP GET request but I get back a 404. I assume there is an issue on the URL but I can't find it.

Here is the function that executes the request:

getMockResource :: (MonadHttp m) =>  m BsResponse 
getMockResource = req
  GET
  (http "www.mocky.io" /: "/v2/5da208d92f00007900f418ff")
  NoReqBody
  bsResponse
  mempty

my main:

main :: IO ()
main = runReq defaultHttpConfig $ do
  r <- getMockResource
  liftIO $ B.putStrLn (responseBody r)

and here is the output:

VanillaHttpException (HttpExceptionRequest Request {
  host                 = "www.mocky.io"
  port                 = 80
  secure               = False
  requestHeaders       = []
  path                 = "/%2Fv2%2F5da208d92f00007900f418ff"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (StatusCodeException (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Server","Cowboy"),("Connection","keep-alive
"),("Date","Sat, 12 Oct 2019 21:09:09 GMT"),("Content-Type","text/html; charset=UTF-8"),("Content-Length","2137"),("Via","1.1 vegur")], responseBody = (), responseCookieJar = CJ {expose = []}, respo
nseClose' = ResponseClose}) "\n\n<!DOCTYPE html>\n<html lang=\"en\">\n    <head>\n        <title>Not Found</title>\n        <link rel=\"shortcut icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANS
UhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAlFJREFUeNqUU8tOFEEUPVVdNV3dPe8xYRBnjGhmBgKjKzCIiQvBoIaNbly5Z+PSv3Aj7DSiP2B0rwkLGVdGgxITSCRIJGSMEQWZR3eVt5sEFBgTb/dN1yv
nnHtPNTPG4PqdHgCMXnPRSZrpSuH8vUJu4DE4rYHDGAZDX62BZttHqTiIayM3gGiXQsgYLEvATaqxU+dy1U13YXapXptpNHY8iwn8KyIAzm1KBdtRZWErpI5lEWTXp5Z/vHpZ3/wyKKwYGGOdAYwR0EZwoezTYApBEIObyELl/aE1/83cp40Pt5mxqCKrE4Ck+mVWK
KcI5tA8BLEhRBKJLjez6a7MLq7XZtp+yyOawwCBtkiBVZDKzRk4NN7NQBMYPHiZDFhXY+p9ff7F961vVcnl4R5I2ykJ5XFN7Ab7Gc61VoipNBKF+PDyztu5lfrSLT/wIwCxq0CAGtXHZTzqR2jtwQiXONma6hHpj9sLT7YaPxfTXuZdBGA02Wi7FS48YiTfj+i2Nhq
tdhP5RC8mh2/Op7y0v6eAcWVLFT8D7kWX5S9mepp+C450MV6aWL1cGnvkxbwHtLW2B9AOkLeUd9KEDuh9fl/7CEj7YH5g+3r/lWfF9In7tPz6T4IIwBJOr1SJyIGQMZQbsh5P9uBq5VJtqHh2mo49pdw5WFoEwKWqWHacaWOjQXWGcifKo6vj5RGS6zykI587XeUIQ
DqJSmAp+lE4qt19W5P9o8+Lma5DcjsC8JiT607lMVkdqQ0Vyh3lHhmh52tfNy78ajXv0rgYzv8"))

The resource is avaliable at http://www.mocky.io/v2/5da208d92f00007900f418ff

Any ideas of where the problem lies? Thank you!

2 Answers
Related