I'm trying to retrieve AN SPListItem from his UniqueID. I can have his document library url like http://mysharepoint.be/MYDOCUMENTLIBRARY but when i try to get the SPList from the name "MYDOCUMENTLIBRARY" it doesn't work because the real name has space like 'MY DOCUMENT LIBRARY'.

Thanks for your help

  • Could you add a sample of the code you are using to help clarify your question? Commented Feb 15, 2014 at 3:55

3 Answers 3


So you have UniqueId of the item and the Url of the library, right? You can get the item in one of the following ways:

  1. Get the list from the Url

    SPList list = web.GetList("http://mysharepoint.be/MYDOCUMENTSLIBRARY");
    SPListItem item = list.GetItemByUniqueId(yourGuid);
  2. Get the list form the Url of a webpart page that has a web part for your list as first web part in the page. You can use Url of any view.

    SPList list = web.GetListFromWebPartPageUrl("http://mysharepoint.be/MYDOCUMENTSLIBRARY/Forms/AllItems.aspx");
    // you can also use web.GetListFromUrl("http://mysharepoint.be/MYDOCUMENTSLIBRARY/Forms/AllItems.aspx");
    SPListItem item = list.GetItemByUniqueId(yourGuid);
  3. If you have SPFolder you can also do the following

    SPListItem item = folder.DocumentLibrary.GetItemByUniqueId(yourGuid);

For lists and libraries, SharePoint locks the URLs to whatever value the name was when the list/library was created. Later, if you rename the list/library, it will reflect the new name everywhere except in the URL.

From your description, it sounds like you are saying the URL.....


.....works, but the library name is really "MY DOCUMENT LIBRARY".

If that is the case, then it means the user named the library "MYDOCUMENTLIBRARY" when they first created it, but they have since renamed to "MY DOCUMENT LIBRARY".

Using this renaming trick is a common 'best practice' since it makes your URLs a bit cleaner as you can avoid the encoded spaces (%20).


Replace your spaces with "%20" (no quotation marks).

For example, http://mysharepoint.be/MY%20DOCUMENT%20LIBRARY

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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