An error occurred [Your InputStream was neither an OLE2 stream, nor an OOXML stream]
I downloaded an attachment from an URL using groovy script . An attachment is in .xlsx format.
But while reading that .xlsx file it is throwing below error:
Your InputStream was neither an OLE2 stream, nor an OOXML stream]
So I tried to read raw response as per suggestions using below snippet:
def DownloadLink="https://bestbuyuat.service-now.com/api/now/attachment/4519d6eb1b592c90a531c8866e4bcb4d/file"
def snowuserauth="Basic"
def userCredentials2="${username}:${passwd}"
ā def httpConn = new URL(DownloadLink).openConnection() as HttpURLConnection
basicAuth1 = "${snowuserauth} " + new String(new sun.misc.BASE64Encoder().encode(userCredentials2.getBytes()));
println("*** encoded1 "+basicAuth1);
httpConn.setRequestProperty ("Authorization", basicAuth1);
int BUFFER_SIZE = 4096;
int responseCode1 = httpConn.getResponseCode();
*def rawResponse = context.httpResponse.getRawResponseBody();
InputStream inputStream = new ByteArrayInputStream(rawResponse);
But then it is giving me below error:
{returnCode=1, errorStream={returnCode=-1000, errorStream=Exeception while executing script: [{}]java.lang.NullPointerException: Cannot get property 'httpResponse' on null object}}
Please suggest on this.
Hi Prajakta_Kale ! Technical questions of this depth are out of my scope, but I did find a similar topic that has a solution - https://community.smartbear.com/t5/API-Functional-Security-Testing/An-error-occurred-Your-InputStream-was-neither-an-OLE2-stream/td-p/181596
Is that something you tried? Please let me know.