title: Exception in thread "main" io.restassured.path.json.exception.JsonPathException: Failed to parse the JSON document while trying to "automate an API "
body: <p>I am getting the following exception while trying to Automate an API:
  Exception in thread &quot;main&quot; io.restassured.path.json.exception.JsonPathException: Failed to parse the JSON document
  at io.restassured.path.json.JsonPath$ExceptionCatcher.invoke(JsonPath.java:1002)
  at io.restassured.path.json.JsonPath$4.doParseWith(JsonPath.java:967)
  at io.restassured.path.json.JsonPath$JsonParser.parseWith(JsonPath.java:1047)
  at io.restassured.path.json.JsonPath.toJsonString(JsonPath.java:1064)
  at io.restassured.path.json.JsonPath.prettify(JsonPath.java:685)
  at io.restassured.path.json.JsonPath.prettyPrint(JsonPath.java:700)
  at ApiAutomation_BDD.ApiAutomation_BDD.bearerToken_GETRequest.main(bearerToken_GETRequest.java:35)
  Caused by: groovy.json.JsonException: Lexing failed on line: 2, column: 1, while reading '&lt;', no possible valid JSON value or punctuation could be recognized.
  at groovy.json.JsonLexer.nextToken(JsonLexer.java:86)
  at groovy.json.JsonLexer$nextToken.call(Unknown Source)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:130)
  at io.restassured.internal.path.json.ConfigurableJsonSlurper.parse(ConfigurableJsonSlurper.groovy:97)
  at io.restassured.internal.path.json.ConfigurableJsonSlurper$parse.callCurrent(Unknown Source)
  at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:171)
  at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:185)
  at io.restassured.internal.path.json.ConfigurableJsonSlurper.parseText(ConfigurableJsonSlurper.groovy:83)
  at io.restassured.path.json.JsonPath$4$1.method(JsonPath.java:965)
  at io.restassured.path.json.JsonPath$ExceptionCatcher.invoke(JsonPath.java:1000)
  ... 6 more</p>
  <p>and the following is the code which I tried (again not sharing any values coz of security risk):</p>
  <pre><code>public static void main(String args[]) throws IOException  {
  RestAssured.baseURI = &quot;{Url}&quot;;
  RequestSpecification httpRequest = RestAssured.given()
                                     .contentType(&quot;x-www-form-urlencoded&quot;)
                                     .formParam(&quot;grant_type&quot;, &quot;&quot;)
                                     .formParam(&quot;client_id&quot;, &quot;&quot;) 
                                     .formParam(&quot;scope&quot;, &quot;&quot;)
                                     .formParam(&quot;client_secret&quot;,&quot;&quot;);
      Response response = httpRequest.request(Method.GET);
      JsonPath res = response.jsonPath();
      //String BearerToken = response.getBody().asString();
      //System.out.println(&quot;The response is:&quot; +res);
      res.prettyPrint();
      int code = response.getStatusCode();
      System.out.println(&quot;The status code is&quot; + code);
      assertEquals(code, 200);
  </code></pre>
  <p>}
  }</p>