1

I am trying post request with rest client builder.

We have following code

RestBuilder rest = new RestBuilder()
rest = rest.post("https://api..com/ff/one"){
    header 'x-pushbots-appid', '550de488b4569'
    header 'x-pushbots-secret', 'e6717aea77d'
    contentType "application/json"
    json {
        token ="APA91bG9rUbBPURYejC1uzDLbqUMaeHulCtBNIYUokqV5QUwelLygKi8c5c2kD2lq05DXiiKJEDgH8NGfM6DFGhCETgSuX5kOr"
        platform="1"
        msg ="sarath test from API call"
        sound ="ding"
        badge ="badge"
        payload ="JSON"
    }
}

Postman is giving correct result for this request , while using rest client builder plugin, response is coming as null. I checked in api doc and code looks fine.

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
Vish
  • 867
  • 6
  • 19
  • 45
  • Start with `json {` in one line instead of two lines as updated in the question. `json()` takes a closure. – dmahapatro Mar 26 '15 at 15:16
  • On a second look, `rest = rest.post("https://api..com/ff/one"){` , the response is assigned back as `RestBuilder` which is incorrect. It should be `RestResponse response = rest.post("https://api..com/ff/one"){ .. }` or just `def response`. – dmahapatro Mar 26 '15 at 15:30
  • hey thanks..def response chnage i addded my mistake during paste code..is they is some way to debug code ..this little bit urgent – Vish Mar 27 '15 at 03:34

1 Answers1

4

it seems i was wrong version of json builder. Issue got fixed after using compile ":rest-client-builder:2.1.1"

Vish
  • 867
  • 6
  • 19
  • 45