以下是我正在运行的代码:
makeRequest = do
response <- httpJSON "GET http://httpbin.org/get" :: IO (Response ())
putStrLn $ "The status code was: " ++ show (getResponseStatusCode response)
中的httpJSON方法
如果我导航到URL http://httpbin.org/get,我可以看到返回的JSON有效。
但是,代码返回以下错误:
Exception: JSONConversionException Request {
host = "httpbin.org"
port = 80
secure = False
requestHeaders = [("Accept","application/json")]
path = "/get"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
(Response {responseStatus = Status {statusCode = 200, statusMessage = "OK"}, responseVersion = HTTP/1.1, responseHeaders = [("Connection","keep-alive"),("Server","meinheld/0.6.1"),("Date","Wed, 01 Nov 2017 15:41:54 GMT"),("Content-Type","application/json"),("Access-Control-Allow-Origin","*"),("Access-Control-Allow-Credentials","true"),("X-Powered-By","Flask"),("X-Processed-Time","0.000639915466309"),("Content-Length","226"),("Via","1.1 vegur")], responseBody = Object (fromList [("origin",String "87.194.144.188"),("args",Object (fromList [])),("url",String "http://httpbin.org/get"),("headers",Object (fromList [("Accept",String "application/json"),("Accept-Encoding",String "gzip"),("Connection",String "close"),("Host",String "httpbin.org")]))]), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) "expected (), encountered Object"
知道我做错了什么吗?
非常感谢。