Forum Discussion

mkajale2's avatar
mkajale2
Occasional Contributor
6 years ago

An error occurred [Your InputStream was neither an OLE2 stream, nor an OOXML stream]

Hi,   Steps -  1. Read response of API and write into XLSX file  - API response content type is ms-excel content disposition as app/filename 2.Read XLSX and coompare with expected xlsx file ...
  • mkajale2's avatar
    mkajale2
    6 years ago

    Hi,

     

    Reading response at run time resolved the issue. 

     

    //read raw response at run time  
    def rawResponse = context.httpResponse.getRawResponseBody();
    InputStream inputStream = new ByteArrayInputStream(rawResponse);

    // write Response to excel file
    def file = new FileOutputStream(ActualExcelFilePath)
    def out = new BufferedOutputStream(file)
    int read = 0;
    byte[] bytes = new byte[1024];
    while ((read = inputStream.read(bytes)) != -1) {
    out.write(bytes, 0, read);
    }
    out.close();