Todd Ropog
Todd Ropog

Reputation: 1142

How to Get the Title of a SharePoint List?

I am trying to retrieve a list from SharePoint using the web services. I ran into the problem described in this blog post, i.e. the GetList method apparently expects to be passed the list's title instead of the list's name (even though the parameter is called "listName"). I have the list's name, but I cannot figure out how to get the list's title. Where can I find that?

I'm using the SharePoint in Office 365, which I believe is 2010.

Upvotes: 1

Views: 6229

Answers (2)

Tamour Ahmad
Tamour Ahmad

Reputation: 135

A little over head but try this code. Its just a sample code, you might want to mould it to your logic.

string listName = "MyList";

Lists.Lists listSvc = new Lists.Lists();
listSvc.UseDefaultCredentials = true;

XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(listSvc.GetListCollection().OuterXml);

XmlNamespaceManager nsmgr = new XmlNamespaceManager(xDoc.NameTable);
nsmgr.AddNamespace("A", "http://schemas.microsoft.com/sharepoint/soap/");

XmlNode requiredList = xDoc.SelectSingleNode("//A:List[contains(@DefaultViewUrl,'" + listName + "')]", nsmgr);
string listTitle = requiredList.Attributes["Title"].Value;

XmlNode list = listSvc.GetList(listTitle);

Upvotes: 1

iamruss
iamruss

Reputation: 812

strListName: Can be either a list name, such as "Documents", or a GUID of the list, with or without curly braces, in the following format:

{318B9E8F-1EF4-4D49-9773-1BD2976772B6}

you may find more info here - the above info is an excerpt from this document

Upvotes: 0

Related Questions