Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, May 16, 2012 10:09 PM
When I use the code below I get the error message "Value does not fall within the expected range." I am using the Microsoft.SharePoint.Client.
CamlQuery query = new CamlQuery();
query.ViewXML = "<View Scope='RecursiveAll' />";
query.FolderServerRelativeUrl = "/mysubfolder";
ListItemCollection listItems = spList.GetItems(query);
clientContext.Load(listItems);
clientContext.ExecuteQuery();
Thanks for any help.
Rich
Rich Stewart
All replies (7)
Thursday, May 17, 2012 9:49 PM âś…Answered | 1 vote
I resolved this problem by changing the FolderServerRelativeUrl property to "/employee/project/Enterprise Project Information/Active Project Status Reports". I hadn't realized the need to include everything after https://...com.
Rich Stewart
Thursday, May 17, 2012 1:28 AM
Make sure to include the url name of the list in the FolderServerRelativeUrl property, for example query.FolderServerRelativeUrl = "/listname/mysubfolder"
Working example:
public static void GetListItemsInFolder() { ClientContext clientContext = new ClientContext("http://basesmc2008"); List list = clientContext.Web.Lists.GetByTitle("tester2"); CamlQuery camlQuery = new CamlQuery(); camlQuery.ViewXml = @"<View Scope='Recursive'> <Query> </Query> </View>"; camlQuery.FolderServerRelativeUrl = "/tester2/whatdown"; ListItemCollection listItems = list.GetItems(camlQuery); clientContext.Load(listItems); clientContext.ExecuteQuery(); ListItem itemOfInterest = listItems[0]; string creator = itemOfInterest.FieldValues["Created_x0020_By"].ToString(); string title = itemOfInterest.FieldValues["Title"].ToString(); }
Blog | SharePoint Field Notes Dev Tool | ClassMaster
Thursday, May 17, 2012 6:31 PM
Steve,
Thanks for the response. Unfortunately, the code below, which is exactly what I'm using, still gives the same error.
Rich
Rich Stewart
Thursday, May 17, 2012 7:19 PM
Have you tried url encoding the string, for instance try "/Enterprise%20Project%20Information/Active%20Project%20Status%20Reports". The title of a list is not necessarily the Url of the list. Titles can be changed and can be different than the Url.
Blog | SharePoint Field Notes Dev Tool | ClassMaster
Thursday, May 17, 2012 8:44 PM
Yes, I tried url encoding the string. It didn't make a difference. I also tried the code on another document library in another site and got the same result.
Rich Stewart
Thursday, May 17, 2012 10:01 PM
Great. I was working from a root site so I only had to include the list name. Good to know.
Blog | SharePoint Field Notes Dev Tool | ClassMaster
Thursday, February 1, 2018 12:28 PM
A thousand thanks Steve. You saved my day. Regards.