Having a few issues with the response handling of my httpbuilder post and json
within my service I have:
def jsonDataToPost = '{"accountNumber" : ' + accNo + ',"accountName" : ' + accName + '}'
def http = new HTTPBuilder('https://myurl.com/dataInput')
def jsonResponse
http.auth.basic ('username','password')
http.request(POST, ContentType.JSON) {
headers.'Content-Type' = 'application/json'
body = jsonDataToPost
response.success = { json ->
println("Success")
jsonResponse = json
}
response.failure = { json ->
println("Fail")
jsonResponse = json
}
}
firstly for some reason the code actually skips out rather than completing and so I'm not getting the jsonReponse I'm after but I can't figure out why? If I reponse my response.success/fail and I post correct data my json post works but again I still get no json back