I am trying to use an API to download documents which will be in either PDF or Word document formats. The service gives directions only up to how to construct the request URL, which I have done.
The API offers an xml or json method in the url, I am using xml.
I have tried to get the string and parsing it to an XDocument:
XDocument response;
using (var webClient = new System.Net.WebClient())
{
response = XDocument.Parse(webClient.DownloadString(url));
}
Console.WriteLine(response);
I also tried downloading as a file:
using (var webClient = new System.Net.WebClient())
{
webClient.DownloadFile(url, filepath));
}
Both produce the same result:
%PDF-1.5
%µµµµ
1 0 obj
<</Type/Catalog/Pages 2 0 R/Lang(en-US) >>
endobj
2 0 obj
<</Type/Pages/Count 2/Kids[ 3 0 R 27 0 R] >>
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R/F2 7 0 R/F3 9 0 R/F4 11 0 R/F5 13 0 R/F6 21 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 18 0 R 19 0 R 20 0 R 26 0 R] /MediaBox[ 0 0 612 792] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S>>
endobj
4 0 obj
<</Filter/FlateDecode/Length 6592>>
stream
xœÝ=k“Û6’ß]åÿÀOYÍžÍo2ÙrÝ8‰sÙ‡Çn²Æ2=¦¡|ó°ãÔþøën€/‘ÐH r]¥"%ˆÝht7ú…KÎïÞ:Q™H•0#R©®xš©ä²¼{çå_ïÞùßíC~ùkRÓ“åi.›B¥Fï÷Œ‡ÏîÞùôK¸I<{y÷K2ø%ŒóTfR™'Ï.îÞÉRø,ÉRžkx•Ery>ñá_ß½óÛ"9ùwòìïwï|ÏÿÑ…J‹¼A„ñ4×r®<a,Í䮺ÈS×\¤ïáZÌ"ë6Ts•*UCd
NUÃS„ªÊ¤<.UU‘š T•9)&U¥NMª
–ʸTðû Te9rRLªò•L
and a lot more like this goes on. It's very odd characters, I am not sure how to parse an XML or PDF document from this.