title: Updating excel with values from rest assured json response using apache-poi
body: <p>I am a newbie with Rest Assured and seek help. I have written code to read values from an excel sheet and pass them as a path params in my Rest Assured tests. And this works as expected. However after I get the json response from the post request I make, I want to update the same excel with values from the response.</p>
  
  <p>The excel has columns called Train number, date of journey and various class codes as other columns like first class code, business class code, standard class code that should show the availabality in them and so on something like this:</p>
  
  <p>Initially:</p>
  
  <pre><code>ServiceName  | Date     | A0 | A1 | A2 | ...... 45 columns
  
  9008         |2019-07-28| 0  |  0 |  0 |....... 45 columns
  </code></pre>
  
  <p>After test:</p>
  
  <pre><code>ServiceName  | Date     | A0 | A1 | A2 | ...... 45 columns
  
  9008         |2019-07-28| 45 | 23 | 64 |....... 45 columns
  </code></pre>
  
  <p>I have followed apache-poi documentation to read values from excel with supporting methods to read rows, columns and getting cell value. However could not find anything that suggests how to update the same excel with the values from Json response. </p>
  
  <p>These are the test and data provider methods I have come up for reading values from excel </p>
  
  <pre><code>@DataProvider(name="logicalAvProvider")
  String [][] getLogicalAv() throws IOException
  {
      String path = "C:\\Misc\\LogAv.xlsx";
      int rownum = XLUtils.getRowCount(path, "LogAv");
      int colcount=XLUtils.getCellCount(path, "LogAv",rownum );
  
      String LogAvData[][] = new String[rownum-1][colcount];
      for (int i=1; i &lt;rownum; i++ ) {
          for (int j=0; j&lt;colcount; j++) {
              LogAvData[i-1][j] = XLUtils.getCellData(path, "LogAv", i, j);
              //System.out.println("Data is " +LogAvData[i-1][j]);
          }
      }
      return(LogAvData);
  }
  
  
  @Test(dataProvider="logicalAvProvider")
  public void LogicalAvailablity(String ServiceName, String Date) throws IOException {
  
      Response res=
      given()
      //.log().all()
      .spec(reqSpec)
  
      .pathParams("service_name", ServiceName, "travel_date", Date)
  
      .when()
      .get(EndPoints.LOGICAL_AVAILABILTY)
      .then()
      .spec(resSpec)
      .extract().response();
      //.log().body();
  </code></pre>
  
  <p>} </p>
  
  <p>This is the sort of response we see after doing the post request. I need the number available to be updated under the respective columns in the excel.</p>
  
  <pre><code>[
  {
      "od_pair": "7015400:8727100",
      "buckets": [
          {
              "bucket": "C00",
              "original": 2,
              "available": 2
          },
          {
              "bucket": "A01",
              "original": 76,
              "available": 0
          },
          {
              "bucket": "B01",
              "original": 672,
              "available": 477
          },
          {
              "bucket": "B03",
              "original": 578,
              "available": 383
          }
  ]
  }
  ]
  </code></pre>
  
  <p>An advice on the approach to update the excel sheet with the values. I am not expecting anyone to give me the exact solution of my problem but any advice on the approach or any reference that I can refer to achieve this would be highly appreciated.</p>