我使用rest-client-builder:1.0.3 grails插件与REST API DSpace进行通信。 这很有效:
def resp = rest.post("http://10.42.0.239:8080/rest/login"){
contentType "application/json"
json{
email = "myemail@mail"
password = "root"
}
}
但我需要以这种方式发送带减号的参数:
def status = rest.get("http://10.42.0.239:8080/rest/status"){
contentType "application/json"
json{
rest-dspace-token = "4506b187-bda8-4db7-801d-635f277d5316"
}
}
在rest-dspace-token中减号会给出下一个错误:
((rest - dspace) - token) is a binary expression, but it should be a variable expression at line
我该如何解决这个问题? 提前谢谢。
答案 0 :(得分:2)
只需将其作为代理人的财产引用:
json{
delegate.'rest-dspace-token' = "4506b187-bda8-4db7-801d-635f277d5316"
}