How to read/load json file directly from server

Hello,

this is not a valid JSON string, therefore JSONSlurper throws an error here. For some reason, it is a mix of HTML and JSON format. To parse only JSON part:

String response = "<html><body>{‘auth_code’: ‘1xxxxxxxxxxxxxxxxxxxxxxx’}</body></html>"

String jsonPart = response.substring(response.indexOf("{"), response.lastIndexOf("}") + 1)

And then you can use JSONSlurper.

def jsonSlurper = new JsonSlurper()
def jsonResponse = jsonSlurper.parseText(jsonPart)