0

I use Grails 2.4.5 and Rest Client Builder 2.1.1 to call an external webservice in my service. Need to signin, signout and validate tokens etc. I followed the doc in this link. the signin() which need a post() and the validate() with needs a post too works good. However, when I'm implementing signout(), which need to use delete() keeps given me this HTTP400 error, keeps saying my token is invalid, however, when I use that token in postman, it work good with a return of HTTP200. I tried all the ways to change the syntax of delete post, however, always returns a 400 error. Since post() works good so I started to thinking maybe it's because the external service returns nothing for delete() method, makes the plugin thinks there's something wrong with it. So my question is, if a http request returns nothing(but it is successful), will rest client builder handles it as an error? if you have the similar problem, please posted it too, as this is a legacy plugin there's not too many questions or documents we can refer to.

Below is the delete() request I did with rest builder:


RestResponse signOutResponse = new RestBuilder().delete("${baseURL}auth-management/auth/sign-out") {
            auth "Bearer ${tk}"
            accept "*/*"
            header "x-api-key", "myXApiKey"
            contentType "application/json"
            json userId: "user"
        }

and this is the curl which works fine in postman:

curl -X 'DELETE' \
  'https://test.com/auth-management/auth/sign-out' \
  -H 'accept: */*' \
  -H 'x-api-key: myXApiKey' \
  -H 'Authorization: Bearer thisIsTheBearerToken' \
  -H 'Content-Type: application/json' \
  -d '{
  "userId": "user"
}'
Anurag Reddy
  • 1,159
  • 11
  • 19
Evan Sun
  • 1
  • 1

0 Answers0