来自docs的帖子示例不适用于http-builder 1.7.1。
def msg = "I'm using HTTPBuilder's RESTClient on ${new Date()}"
def resp = twitter.post(
path : 'update.json',
body : [ status:msg, source:'httpbuilder' ],
requestContentType : URLENC )
assert resp.status == 200
assert resp.headers.Status
assert resp.data.text == msg
def postID = resp.data.id
例外是
wslite.rest.RESTClientException: No such property: body for class: wslite.http.HTTPRequest
拖曳API,应该如何正确构造帖子并不明显。有任何想法吗?
根据异常,您似乎正在使用groovy-wslite库而不是HTTPBuilder。在这种情况下,应该可以进行以下操作:
def resp = twitter.post(path: 'update.json') {
urlenc status: msg, source:'httpbuilder'
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句