Open sfrogner opened 8 years ago
i cannot get the response body at all for any error response it seems. i think you are seeing the same thing
did you ever find a solution to this problem?
I reproduced the problem. After pasting in the following lines above the sample code:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7')
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseException
import static groovyx.net.http.ContentType.*
...and replacing the last commented-out line with
println "Content: " + (r.data ? "\n${JsonOutput.prettyPrint(JsonOutput.toJson(r.data))}" : r.data)
Was curious if anyone has seen this issue? I have tested this call with insomnia and it returns with 200 Ok.
def https = new RESTClient('https://d.la10.salesforceliveagent.com/chat/rest/')
def payload = [ "organizationId":"00D28000000f5N9", "deploymentId":"572280000008R6L", "buttonId":"573D000000000OC", "agentId":"005B0000000F3b2", "doFallback":true, "sessionId":sid, "userAgent":"Lynx/2.8.8", "screenResolution":"2560x1440", "visitorName":"Gerald", "prechatDetails":prechat, "prechatEntities":PreEnt, "receiveQueueUpdates":true, "isPost":true, "language":"en-US" ] println(payload) def myheaders = [ 'Content-Type': 'application/json', 'X-LIVEAGENT-API-VERSION':'36', 'X-LIVEAGENT-SEQUENCE':'1', 'X-LIVEAGENT-SESSION-KEY': skey, 'X-LIVEAGENT-AFFINITY': stoken ]
try { def resp = https.post( path:'Chasitor/ChasitorInit', requestContentType: JSON, headers: myheaders, body:payload, )
} catch(HttpResponseException e) { r = e.response println("Success: $r.success") println("Status: $r.status") println("Reason: $r.statusLine.reasonPhrase") //println("Content: \n${JsonOutput.prettyPrint(JsonOutput.toJson(r.data))}") }
I always get the following May 15, 2016 10:06:22 AM groovyx.net.http.RESTClient handleResponse WARNING: Error parsing 'application/json' response groovy.json.JsonException: Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'O' with an int value of 79 Unable to determine the current character, it is not a string, number, array, or object line number 1 index number 0 OK
Success: true Status: 200 Reason: OK