0
我尝试从HTTPBuilder的URL获取JSON,但此代码返回Exception,返回此错误“方法抛出'groovy.lang.MissingPropertyException'异常。”测试API Grails
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
}