title: How can we do Parallel Execution of API Test Cases(GET/POST) using Rest Assured based Framework
body: <p>Please find the below base class for API request. Due to static request/response, I am not able to do parallel test execution. My framework is based on Cucumber, Junit, Java, Json based request.</p>
  <pre><code> public class APIreq {
  private static Integer statusCode = 0;
  private static String statusLine = null;
  private static String resource = null;
  protected static Response getResponse;
  protected static Response postResponse;
  public static JSONObject request = null;
  public static JSONObject fileRequest = null;
  
  protected static void postRequest(JSONObject requestBody, String endpoint) throws IOException {
      resource1 = endpoint;
      request = requestBody;
      HashMap&lt;String, String&gt; headerMap = new HashMap&lt;&gt;();
      headerMap.put( &quot;Content-Type&quot;, &quot;application/json&quot; );
      headerMap.put(&quot;Authorization&quot;,ABCD);
  
      try {
          postResponse = RestAssured.given()
                  .log()
                  .all()
                  .headers( headerMap )
                  .body( request.toString() )
                  .post( Hooks.targetURL + resource1 )
                  .then()
                  .extract()
                  .response();
          postResponse.prettyPrint();
          statusCode = postResponse.getStatusCode();
          statusLine = postResponse.getStatusLine();
      } catch (Exception e) {
          logger.error( &quot;Error: &quot; + e.getMessage() );
      }
  }
  public static void assertJsonPostReq(String attribute, String expectedValue) {
      io.restassured.path.json.JsonPath jsonPathEvaluator = postResponse.jsonPath();
      String attributeValue = jsonPathEvaluator.get(attribute);
      SYSO( attribute + &quot;: Expected: &quot; + expectedValue + &quot;, Actual: &quot; + attributeValue );
      Assert.assertTrue(attributeValue.contains(expectedValue));
  }
  </code></pre>
  <p>}</p>