I am trying to write a C# desktop app (a simple console application for now) using which I can upload a file to our Skydrive Pro instance (which is accessible using the same API's as that of SharePoint) using a REST api

I have tried a number of solutions, too many to start listing here, but given the number of roadblocks I am facing, my guess is that I am doing something fundamentally wrong.

One of the methods I used was: http://blog.cloudshare.com/2012/12/16/access-and-manipulate-data-in-your-cloudshare-sharepoint-2013-farm-from-anywhere-with-csom-rest-and-odata/ which fails in the GetFormDigest function, specifically in

        HttpWebResponse responsePost = (HttpWebResponse)requestPost.GetResponse();

giving a HTTP 500 error. Looking at the error in Fiddler, it says there is an authentication issue even though I am able to see some authentication data being passed in the request, the code I used for authentication was:

        requestPost.Credentials = CredentialCache.DefaultCredentials;
        requestPost.UseDefaultCredentials = true;
        requestPost.Method = "POST";
        requestPost.ContentLength = 0;

Any advice\tutorials\walkthroughs would be appreciated


In the code example that you mentioned, the author did't use default credentials, he specified a login name and password. Like this:

ClientContext context = new ClientContext(siteUrl);
context.AuthenticationMode = ClientAuthenticationMode.Default;

// Obtain these values from your environment's home page
context.Credentials = new NetworkCredential("username", "password", "domain");

If you aren't providing login credentials, I would expect the server to think you were some anonymous user, and reject you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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