try {
def contactId= "9999"
def phoneNumber = 213213214
def postObj = [PhoneNumber: phoneNumber,
ContactID : contactId]
def queryString = ["processAgainstExisting": true]
def params = ["restVerb" : "POST",
"postObj" : postObj,
"path" : "/contact/$contactId/PhoneNumber",
"query" : queryString]
def response = new PostRequest("Some url")
.setParams(params)
.execute()
// check HttpResponse status code
if (response.status != 200) {
throw new RuntimeException(response.statusLine)
}
} catch (Throwable e) {
throw e
}
绑了这篇文章,并遇到了这个问题。 捕获:java.lang.ClassCastException:java.util.LinkedHashMap无法转换为java.lang.String
还有其他方法可以解决此问题吗?
答案 0 :(得分:0)
似乎在线
throw new RuntimeException(response.statusLine)
引起异常,不是吗?
尝试
throw new RuntimeException(response.statusLine.toString())
statusLine
不是String
,但是RuntimeException
需要向构造函数发送String
消息。
https://hc.apache.org/httpcomponents-core-ga/httpcore/apidocs/org/apache/http/StatusLine.html