我收到了这个错误,但我的方法对来说非常好
def http = new HTTPBuilder()
http.request(
'https://textalytics-topics-extraction-11.p.mashape.com/topics-1.2?txt=ben',
Method.GET,
ContentType.JSON
) { req ->
headers."X-Mashape-Key" = "mashkey"
response.success = { resp, reader ->
assert resp.statusLine.statusCode == 200
println "Got response: ${resp.statusLine}"
println "Content-Type: ${resp.headers.'Content-Type'}"
println reader.text
}
response.'404' = {
println 'Not found'
}
}
有什么想法吗?
假设HTTP不可接受意味着:
406不可接受
请求标识的资源只能生成具有不可接受的内容特征的响应实体根据在请求中发送的接受报头。
然后,他们的API可能很挑剔,您需要使用Accept
头指定响应为JSON,使用类似Accept: application/json
的东西。