0

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?

0

1 Answer 1

1

Difference is that PUT is used in RestBuilder whereas POST in curl.

PUT "Method not allowed". Use post() instead.

Sign up to request clarification or add additional context in comments.

1 Comment

This is what happens when you write code after midnigth. And I've been looking at this for an hour. Shame ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.