Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am creating an AutoHosted App in SP 2013 and trying to access the file under one folder of remote Web ( need to pick the file from current project directory location and pass that file to another function).

When I hit the debugging point, I am getting error of ("Cannot invoke HTTP DAV request. There is a pending query."). I am using below code to open the file(Folder1 is the folder and abc.txt is the file which I need to pick):

Creation of context: // The following code gets the client context and Title property by using TokenHelper. // To access other properties, you may need to request permissions on the host web.

        var contextToken = TokenHelper.GetContextTokenFromRequest(Page.Request);
        var hostWeb = Page.Request["SPHostUrl"];

        using (var clientContext = TokenHelper.GetClientContextWithContextToken(hostWeb, contextToken, Request.Url.Authority))

Accessing the file:

Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext , "/Folder1/abc.txt")

Currently I am calling this from aspx.cs file of remote web. I have given the full control to Web and Site Collection in AppMenifest. Is there any way I can get the access to this file?

Thanks in advance!!!!

share|improve this question
Hope you've figured out the solution. Please share if you've, i'm also facing the same error. I'm trying to read a file from a document library and then upload it to google drive. –  AshishRawat Feb 21 at 13:57
add comment

1 Answer

You should try accessing the file by its path in your App.

e.g. ~/Folder1/abc.txt

Or use the Server.MapPath() method.

Btw, you can also use the System.IO namespace (e.g. StreamReader) to read a file on and from the remote web.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.