如何使用GrailsRestBuilder发布用户名和密码

如何使用GrailsRestBuilder发布用户名和密码,grails,Grails,我正在尝试使用RestBuilder执行以下操作 curl -X POST --header "Content-Type: application/xml;charset=UTF-8" --data "</xml_goes_here>" http://www.example.com/api/ -u username:password 有人处理过这个问题吗?试试: def resp = new RestBuilder().post(url) { auth username, p

我正在尝试使用RestBuilder执行以下操作

curl -X POST --header "Content-Type: application/xml;charset=UTF-8" --data "</xml_goes_here>" http://www.example.com/api/  -u username:password
有人处理过这个问题吗?

试试:

def resp = new RestBuilder().post(url) {
  auth username, password
  // the rest
}
尝试:

def resp = new RestBuilder().post(url) {
  auth username, password
  // the rest
}