CSV Report returning as binary data

Prior to this week, I was able to retrieve reports without any problem. After getting the API back up today, I noticed that the data being returned from the report that I requested was coming back all jumbled. I believe it's coming back as a binary file and not text as it was previously. I am setting the format using report.setFormat(APIResultFileType.CSV) in Java. Is this expected behavior Should I be doing something different to read the result Is there encryption going on

Thanks,
Luke


Answer this question

CSV Report returning as binary data

  • New-Bee

    The issue seems to be zipping-related -- our support staff is working on this currently. Please follow up directly with them...

    Sorry,

    Shai


  • genel

    Hi Guys,

    //Here is the solution – works fine for us:

    //Make connection:

    // Open URL connection

    URL u = new URL(url);

    URLConnection conn = u.openConnection();

    conn.connect();

    //Set File:

    String filename = "MSN_KeywordPerformanceReport.zip" + reportId + "_" + c.get(Calendar.YEAR) + "_" +

    c.get(Calendar.MONTH) + "_" + c.get(Calendar.DATE) + "_" + c.get(Calendar.HOUR_OF_DAY) + "_" +

    c.get(Calendar.MINUTE) + "_" + c.get(Calendar.SECOND) + ".zip";

    File zipfile = new File(filename);

    //Create an Output stream:

    ByteArrayOutputStream baos = new ByteArrayO

    File zipfile = new File(filename);

    ByteArrayOutputStream baos = new ByteArrayOutputStream();

    BufferedOutputStream bos = new BufferedOutputStream(baos);

    //ByteArrayOutputStream is purely to read bytes from the downloaded file. Any slight change in byte will make the resultant file corrupted. This Class works fine for us.

    //Reading file using Buffered Reader:

    BufferedInputStream bis = new BufferedInputStream(conn.getInputStream());

    byte[] buffer = new byte[1024 * 10];

    int bytesRead = bis.read(buffer);

    while ((bytesRead != -1))

    {

    bos.write(buffer, 0, bytesRead);

    bytesRead = bis.read(buffer);

    }

    bis.close();

    baos.close();

    bos.close();

    Note: As mentioned by Luke and Justin, we were facing the same problem with the resultant [downloaded] file. Use known API to un-zip the downloaded file.



  • caseymanus

    Luke,
    Be aware that ALL reports are zipped as the default, one no longer controls this via a parameter.

    Feel free to contact me for C# examples to process, I am using the ICSharpcode opensource project to inflate the report.
    David

  • spattewar

    I have the same problem here......all I get back is a load of junk ( )'#][3dnbdwq'#' etc..... )

    Is this a new communication lang MS are working on ;)

    I guess its due to the fact the files are zipped


  • TheMaj0r

    Hello Luke,

    I apologize for any misunderstanding, there is currently no known issue with adCenter itself involving our report-zip files.

    I would encourage you to pursue a support ticket with your current issue, this will enable us to provide a more complete assistance to you, especially concerning the more private details of your account, such as account structures, BI data, etc.

    Whether you proceed with a ticket or not, I would like to examine the zip file you recieved if you wouldn't mind sending it to me. First, would you please re-run the report and obtain a "fresh" file from our webservice Then, please send me the resulting file, unaltered so I can comment on the problem you are experiencing.

    Please send me the zip file at the following address: jason.dujardin-terry@microsoft.com

    I appreciate your patience and understanding.

    Best Regards,

    JasonDT - MSFT


  • Todd Virlee

    Fahad,

    When you unzip the input stream, are you actually getting data out I am getting an empty string. Here is the relevant code I am using.

    private static void extract(ZipInputStream in, OutputStream out)

    throws IOException {
    byte[] buffer = new byte[32768];
    for (int length; (length = in.read(buffer, 0, buffer.length)) != -1; ) {
    out.write(buffer, 0, length);
    }
    }

    <CODE>
    extract(new ZipInputStream(get.getResponseBodyAsStream()), out);
    String result = out.toString("UTF-8");
    </CODE>


    Thanks,
    Luke

  • ajliaks

    Hi,

    We are also experiencing the same issue since morning. We know that the default file type is “zip”, we have confirmed the downloaded file type with the code as well. But when we try to un-zip the file, it is appearing to be a binary/corrupted file.

    We were expecting the XML type in response.

    Is it a know issue

    Any input from MSN support

    Looking forward of an early reply.

    Environment we are using:

    We are working on the production environment.

    MSN API Version: V3

    Compiler: jdk1.5



  • HeathM

    Hello,

    Here are some tips to ensure that you don't experience this problem:

    • Make sure that you download the report file as BINARY and not ASCII, we will always send you a ZIP file.
    • Once you have successfully downloaded the zipped report file, please make sure to unzip the file.
    • There are number of ways to unzip the file once it has been downloaded. If there is a concern as to the integrity of said file, I reccomend performing a test using a known-working zip program in addition to unzipping from code.

    I hope this helps , please reply should you have any further questions or comments.

    Best Regards,

    JasonDT - MSFT


  • TapasChoudhury

    Is this issue resolved on the AdCenter side I was told that this was a known issue and MSFT was working to resolve the problem. If it is resolved, is there anyone out there that has gotten this to work in Java I am attempting to unzip the file with no success (see code in previous post).

    Thanks,
    Luke

  • CSV Report returning as binary data