1
        HttpWebRequest wr = (HttpWebRequest)HttpWebRequest.Create(new Uri("https://sharepointurl/_api/lists/"));
        wr.Credentials = CredentialCache.DefaultNetworkCredentials;
        var v = wr.GetResponse();

On executing the request, I get a HTTP 500 error.

The URL returns the data successfully in IE

Any pointers as to whats wrong?

2
  • Can you do a capture or get more details regarding the response via debugging? What do your HTTP headers look like for this request? Aug 20, 2013 at 15:20
  • Strange, that code snippet works for me. What if you specify the credentials: CredentialCache creds = new CredentialCache(); creds.Add(new Uri(reqUrl), "NTLM", new NetworkCredential("username", "password", "domain")); wr.Credentials = creds; Sep 4, 2014 at 13:17

1 Answer 1

1

More than likely, you are missing some required headers. Did you look at the error message associated with the 500 code? To do that you should a program like fiddler.

Also, check out the documentation here: http://msdn.microsoft.com/en-us/library/office/apps/jj164022.aspx. It describes out to use the 2013 REST API and documents the use of the headers you need.

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.