SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this client OM code to add a new file in a doc.lib.:

            (o, args) =>
                var fileCreationInformation = new FileCreationInformation();
                fileCreationInformation.Content = System.Text.Encoding.Unicode.GetBytes(reportContent);
                fileCreationInformation.Overwrite = true;
                var uploadLocation = string.Format("{0}/{1}", reports.RootFolder.ServerRelativeUrl, title + STR_Extension);
                fileCreationInformation.Url = uploadLocation;                    
                Microsoft.SharePoint.Client.File newFile = reports.RootFolder.Files.Add(fileCreationInformation);

                ListItem newItem = newFile.ListItemAllFields;

                    (o1, args1) =>


When context client have Full control permissions or Design permissions is working perfect. But I get Exception when user have only Contribute permissions to doc.lib. Of course I can create a new report or upload a new report using the browser, but the code is not working in this case.

Any clue ?

Thank you

share|improve this question

A couple things to look at.

Can you remove:

ListItem newItem = newFile.ListItemAllFields;

I don't think they do anything in this'd use these after you uploaded the file to get the list item reference if you were adding metadata.

I'm also not sure I understand the point of the dual ExecuteQueryAsync calls. You could minimally convert the 2nd one to ExecuteQuery as you're already in an async context with the 1st one:


Not sure if changing either of these would address your permissions issues, but it may.

share|improve this answer
Hi, thanx for tip with single ExecuteQueryAsync, you are right. I did test by removing the ListItem load but that didn't change. See the answer next. – Ovidiu Becheş-Puia Jul 30 '11 at 21:57
up vote 0 down vote accepted

I did find the issue: the file getting added is a html report, but to allow user to see in browser the content of the file without downloading it (which is the def. action for html files on SP) I was changing the extension of the file from .html to .aspx :). Is working ok until the user doing the report has only contribute permission on doc.lib. In this case SP denies upload of aspx files. So the fix was to set the extension to html instead of aspx :)

Thanx again Rob.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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