Sign up ×

I am creating some customized web services for my client. I needed to fetch all the tasks in a Sharepoint list. I used following code for that:

NetworkCredential credentials = new NetworkCredential("user", "pass", "domain");
ListService.Lists objLists = new ListService.Lists();
                objLists.Url = "http://server:port/subsite/_vti_bin/Lists.asmx";
                objLists.Credentials = credentials;
                objLists.proxy=new webProxy();
XmlNode objQueryOptions = objXMLDocument.DocumentElement;
                resultXml = objLists.GetListItems("Project Server Workflow Tasks", null, null, null, "100", objQueryOptions, null);
                XElement xresult = GetXElement(resultXml);

But the problem is problem is this code is returning MyTasks instead of AllTasks which it is supposed to return. As on my local server same code returns all tasks and if change the List name in the code to Tasks than the client server also returns All tasks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

As written your query depends on what the users has selected to be the default view for the list.

The documentation for Lists.GetListItems specifies following:

public XmlNode GetListItems(
    string listName,
    string viewName,
    XmlNode query,
    XmlNode viewFields,
    string rowLimit,
    XmlNode queryOptions,
    string webID

viewName: If this parameter contains an empty string, the default view is used
query: If supplied, the value of this parameter overrides either the query within the view

So by setting both to null you specify get me the items of the default view which for the list specified apparently are MyTasks. If you care about which columns you get back you probably also want to set viewFields

share|improve this answer

Your Answer


