【发布时间】:2015-06-04 20:53:12
【问题描述】:
我正在尝试通过 RESTClient 中的 get 方法获取 JSON 文件。
我正在尝试
def url = 'http://urlurlurl'
def username = 'username'
def password = 'password'
def restClient = new RESTClient(url)
restClient.auth.basic(username, password)
render restClient
当我看到我从 restClient 得到的,只是打印出来的
'groovyx.net.http.RESTClient@65333e2e'
这很难理解。
鉴于 url 是 API get 方法的端点,并且包含 JSON 文件,我如何检索 JSON 文件以便解析并使用该 JSON 文件?
我也在尝试这个
def url = 'http://urlurlurl'
def username = 'username'
def password = 'password'
def restClient = new RESTClient(url)
restClient.auth.basic(username, password)
//Adding get method
def jsonData = restClient.get(/* what value should I put in here?? */)
这给了我一个禁止的错误:
Error 500: Internal Server Error
URI: JsonRender
Class: groovyx.net.http.HttpResponseException
Message: Forbidden
有什么建议吗?在 RESTClient 中使用 get 方法的例子会很好。
【问题讨论】:
标签: authentication grails plugins basic-authentication rest-client