Forum Discussion
Xiaoyuan Zhang
Jul 14, 2017Former Employee
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
Sort By
- sunny rajpalCopper 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/
Document Library URL is https://XXX.sharepoint.com/teams/AAA/ + Shared Documents i.e. https://XXX.sharepoint.com/teams/AAA/Shared Documents/
So to get the site url just remove the Shared documents
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
- Xiaoyuan ZhangFormer EmployeeHow can I use CSOM when I don't know site url ?
- sagar savaliyaCopper ContributorYou 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.
- Xiaoyuan ZhangFormer EmployeeI don't have _spPageContextInfo. My code not based on SPO.
- Manidurai MohanamariappanIron Contributor
Yes , you are correct, after removing /shared dodument/ you will get the site url.
- Xiaoyuan ZhangFormer EmployeeDo you have some document of this ? I see some other list url like this
https://xxx.com/teams/aa/bb/
BB not always shared documents, should I remove last segment to get site url?- Manidurai MohanamariappanIron 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