Quantcast
Viewing all articles
Browse latest Browse all 26374

Office 365 (SharePoint 2013): 403 Access Denied Error on attempt to create file using Client Object Model

Hi,

When using Microsoft.SharePoint.client.dll against Office 365  I receive the following error message when my program is attempting to save a file (uploading to SharePoint).

As shown below, here is a the code snippet:

MsOnlineClaimsHelper claimsHelper = new MsOnlineClaimsHelper(SiteUrl, Username, Password);
context.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
string fileName = Path.GetFileName(path);
string relativeurl = rooturl + doclibrary + "/" + fileName;
using (FileStream fs = new FileStream(path, FileMode.Open))
                {<var></var>
                    try
                    {
                        Microsoft.SharePoint.Client.File.SaveBinaryDirect(context, relativeurl, fs, true);
      }
  }

// The above code while saving the file is giving error 

This results in the following error:

{"The remote server returned an error: (403) Forbidden."}

Stacktrace --  "   at System.Net.HttpWebRequest.GetResponse()\r\n   at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.File.SaveBinary(ClientContext context, String serverRelativeUrl, Stream stream, String etag, Boolean overwriteIfExists, SaveBinaryCheckMode checkMode)
   at Microsoft.SharePoint.Client.File.SaveBinaryDirect(ClientContext context, String serverRelativeUrl, Stream stream, Boolean overwriteIfExists)

Any suggestions on resolving this would be greatly appreciated...


Viewing all articles
Browse latest Browse all 26374

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>