如何使用grails 3.3.9在RestBuilder的post请求中发送头
我有上面的代码。当我通过API调用发送post请求时,我得到一个异常“代理票证必须作为标头中的参数发送”。我不知道代码出了什么问题。有人能帮我吗?有不同的方法。这应该起作用:如何使用grails 3.3.9在RestBuilder的post请求中发送头,grails,groovy,Grails,Groovy,我有上面的代码。当我通过API调用发送post请求时,我得到一个异常“代理票证必须作为标头中的参数发送”。我不知道代码出了什么问题。有人能帮我吗?有不同的方法。这应该起作用: Response response = new RestBuilder.post(finalUrl){ header: ["ticket", "getProxyTicket()", "name", "abc", "id", "1"
Response response = new RestBuilder.post(finalUrl){
header: ["ticket", "getProxyTicket()",
"name", "abc",
"id", "1"
]
contentType: application/json
json data
}
可能重复的
new RestBuilder().post(finalUrl){
// this will work if you want the value
// of the ticket header to be the literal "getProxyTicket()".
// if you are trying to invoke a method and you want the return
// value of that method to be the header value, remove the double
// quotes around getProxyTicket()
header "ticket", "getProxyTicket()"
header "name", "abc"
header "id", "1"
// no need to set the content type, the
// json method below will do that
// contentType: application/json
json data
}