I am creating an AutoHosted App in SP 2013 and trying to access the file under one folder of the 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))
{
clientContext.Load(clientContext.Web);
clientContext.ExecuteQuery();
Response.Write(clientContext.Web.Title);
Accessing the file:
Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext , "/Folder1/abc.txt")
Currently I am calling this from the aspx.cs
file of the remote web. I have given the full control to Web and Site Collection in AppManifest
. Is there any way I can get the access to this file?
Thanks in advance!