I’m trying to access a file in a SharePoint list using System.Net.WebClient. The list has anonymous access disabled (when we turn it on, it works) and we’re using Claims-Based Authentication. I know that there are other ways of accessing a file in a SharePoint list, however this is regarding a call that I make to an Office Web Apps web service where I have to pass the URL of a file I want it to generate an image of. Both calling the OWA web service with this URL and trying to download the file directly via WebClient yield the same error.

The error is 403 forbidden, which after some googling I believe the cause is somehow related to using Claims-Based Authentication. I’ve tried a number of the suggested remedies, but so far nothing has worked. I can access the file and the web service using a browser and it works after I get an authentication challenge. If I fail the authentication challenge intentionally I get a 401 error (not a 403), so I don’t believe there’s anything wrong with the credentials (I’ve gone so far as to hard-code them). I’ve tried running the code with RunWithElevated Privileges, but that doesn’t help.

Here is some sample code:

```

    using (var webClient = new WebClient())
    {
    webClient.UseDefaultCredentials = true;
    byte[] result = webClient.DownloadData(urlOfFileInList);
    }

```

Any help is appreciated!