I'm trying to download a document from a autohosted app. I've changed the methodGetClientContextWithAccessToken and change the User Agent like this:UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)";
This change resolved the 403 Error. But when I try to download an office document, I'm receiving only a HTML page (extract):
<!-- ServerInfo: CO1IDOALGN55 2013.02.01.17.11.52 Live1 Unknown LocVer:0 --><!-- PreprocessInfo: BTSA007:RR1BLDA059, -- Version: 11,0,18329,0 --><!-- RequestLCID: 1033, Market:EN-US, PrefCountry: US, LangLCID: 1033, LangISO: EN --><meta content="text/html; charset=utf-8" http-equiv="Content-Type" />...
That is my actual code:
listItem = targetList.GetItemById(id); clientContext.Load(listItem, item => item.DisplayName, item => item["FileRef"]); clientContext.ExecuteQuery(); string fileRef = listItem["FileRef"].ToString(); fInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, fileRef);
Then I save the fInfo.Stream to disk and I have only the above HTML in the result file.
It is possible to download a file from an autohosted app with CSOM?
-