0

The current character read is '<' with an int value of 60 Unable to determine the current character, it is not a string, number, array, or object line number 1 index number 0

*body for the POST method*
```
def jsonBody = [
"grant_type": "refresh_token",
"client_id": "XXXXXXXXXXXXXXXX",
"refresh_token": "XXXXXXXXXXXXXXXXXXXXXXX"
]
def http = new HTTPBuilder('https://account.uipath.com/oauth/token') 

http.request(POST, ContentType.JSON) {

//requestContentType = ContentType.JSON

print("inside the request body")
request.addHeader("ContentType", "application/json")

request.addHeader("Host","")

request.addHeader("X-UIPATH-TenantName","XXXXXXXXXXXXX")
print(jsonBody)
body = jsonBody
print("After json body")
response.success = { resp, JSON ->
JSON ?: [:]
print("Success ")
print("Success "+resp)
}

response.failure = { resp, JSON ->
JSON ?: [:]
print("Fail "
print("Fail "+JSON)
}
}```
Conor
  • 736
  • 1
  • 13
  • 33

1 Answers1

0

Since you are using http.request(POST, ContentType.JSON) {...}, HTTPBuilder will assume that both the request and the response are json. In other words, it will try to parse the response as json even if it is, say, html and even if the response content-type header indicates that it is html.

I would guess your post request results in an error which in turn is returned in the response as a html page with some error text on it. You try to parse this error as json and end up with the failure in your question.

You could try with ContentType.ANY to see what the response is. After that, it might be worth reading up on the javadocs for HTTPBuilder where they have extensive detail on content type handling, both for the request and the response.

Matias Bjarland
  • 4,124
  • 1
  • 13
  • 21