Reputation: 613
I'm trying to consume a REST service that requires me to supply login details in JSON:
def resp = new RestBuilder().put("https://..."){
contentType "application/json"
accept "application/json"
header "X-ESA-API-Key", "ROBOT"
json {
type = "STANDARD_LOGIN"
login = "username"
password = "password"
}
}
This results in the service responding “Method not allowed”.
However, using cURL:
$ curl --compressed \
-X POST \
-d '{"type":"STANDARD_LOGIN","login":"username","password":"password"}' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'X-ESA-API-Key: ROBOT' \
'https://...
I get a proper response and authentication from the service.
Can someone tell me what I'm doing wrong in Grails or how to debug this issue?
Upvotes: 0
Views: 666
Reputation: 50275
Difference is that PUT
is used in RestBuilder
whereas POST
in curl
.
PUT
"Method not allowed". Use post()
instead.
Upvotes: 1