CSV Report returning as binary data
Thanks,
Luke
Thanks,
Luke
Feel free to contact me for C# examples to process, I am using the ICSharpcode opensource project to inflate the report.
David
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
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?
The issue seems to be zipping-related -- our support staff is working on this currently. Please follow up directly with them...
Sorry,
Shai
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 { buffer = new byte[32768]; (int length; (length = in.read(buffer, 0, buffer.length)) != -1; ) { out); out.toString("UTF-8");
byte[]
for
out.write(buffer, 0, length);
}
}
<CODE>
extract(new ZipInputStream(get.getResponseBodyAsStream()),
String result =
</CODE>
Hello,
Here are some tips to ensure that you don't experience this problem:
I hope this helps
, please reply should you have any further questions or comments.
Best Regards,
JasonDT - MSFT
Thanks,
Luke
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
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.