【发布时间】:2017-03-31 16:37:37
【问题描述】:
我尝试从 HTTPBuilder 的 URL 获取 JSON,但此代码返回异常,返回此错误“方法抛出了 'groovy.lang.MissingPropertyException' 异常。”
static request(String path, boolean isGet){
def myClient = new HTTPBuilder("${HOST}${path}")
def jsonResp = [:]
try{
if(isGet){
log.info "[EXAMPLE GET] ${HOST}${path}"
myClient.get(requestContentType: ContentType.JSON){ resp, json ->
jsonResp = resp
}
}
}catch(Exception e){
println "erro: "
log.info "[EXAMPLE ERROR]: ${e.message}"
println(e.message)
}
jsonResp
}
【问题讨论】: