Forum Discussion

Xiaoyuan Zhang's avatar
Xiaoyuan Zhang
Former Employee
Jul 14, 2017

What's the relationship between list url and site url

I need make CSOM call, when I new a context, I need the site url. But I only have list document url, such as 

https://XXX.sharepoint.com/teams/AAA/Shared Documents/

 

Should I remove last "Shared Documents/" to get site url ? Thanks.

10 Replies

  • sunny rajpal's avatar
    sunny rajpal
    Copper Contributor

    SharePoint list/library url is basically adding the library name to the site url and in your case  it is like

     

    Site URL https://xxx.sharepoint.com/teams/AAA/Shared

     

    Document Library URL is https://xxx.sharepoint.com/teams/AAA/Shared + Shared Documents i.e. https://xxx.sharepoint.com/teams/AAA/Shared Documents/

     

     

    So to get the site url just remove the Shared documents

    • Pieter Veenstra's avatar
      Pieter Veenstra
      MVP

      Can you give some more details on what you are trying to do. 

       

      If you are for example using CSOM you could get a list object using the list url and then via list.ParentWeb get the url of the site

  • sagar savaliya's avatar
    sagar savaliya
    Copper Contributor
    You can get site url by "_spPageContextInfo.webAbsoluteUrl" also. I think it would be easy for you. No need to make a CSOM call for that.
      • Manidurai Mohanamariappan's avatar
        Manidurai Mohanamariappan
        Iron Contributor

        Hi,

        In basically site url forming like https//xxx.com/sites/sitename and your case https//xxx.com/teams/sitename so if you remove after site name you will get site url

Resources