Please specify what version of the library you are using: 2.0.3
Please specify what version(s) of SharePoint you are targeting: Online
The idea is to propose tenant scoped functions that are available in the REST API like:
It could be requested like this : sp.tenant.getSitePropertiesByUrl('https://contoso.sharepoint.com/sites/hr', true)
The library will be able to setup an instance to the Admin Site in the background if not exists, so that each method called will refer to the Admin Site instance.
Possible ? Relevant ?
Def possible - been a bit since I checked what is actually exposed via REST from that API. I think re-checking that would be a first step to see what we could effectively surface.
Great, I'll have a look and let you know if you want.
Thanks @michaelmaillot - I will be on leave so please don't be discouraged if I don't respond immediately. Excited to see what we can support here.
Wow, that is exactly what I need right now (I think). I want to set the external sharing property of a site.
In Powershell we do it like
Set-PnPTenantSite -Url $sharepointurl -sharing "ExistingExternalUserSharingOnly"
Is there any other pnpjs or other way to achieve this?
Hi @mplwork !
I know there's an endpoint for this : _https://contoso-admin.sharepoint.com/_api/Microsoft.Online.SharePoint.TenantAdministration.SiteProperties("https://contoso.sharepoint.com/sites/blog")/Update_
Reference here.
You can also achieve this through CSOM (example here).
But I didn't try it.
Hi @mplwork !
I know there's an endpoint for this : _https://contoso-admin.sharepoint.com/_api/Microsoft.Online.SharePoint.TenantAdministration.SiteProperties("https://contoso.sharepoint.com/sites/blog")/Update_
Reference here.
Thanks very much for the link but I can't get it to work. What is the actual URL?
I tried
https://mytenant-admin.sharepoint.com/_api/Microsoft.Online.SharePoint.TenantAdministration.SiteProperties("https://mytenant.sharepoint.com/sites/og_0002")/Update
but whatever I try (with /Update or without) I get a
Microsoft.SharePoint.Client.InvalidClientQueryException.
"The expression "Microsoft.Online.SharePoint.TenantAdministration.SiteProperties("https:/mytenant.sharepoint.com/sites/og_0002")/Update" is not valid."
My token is apparently working as I first tried without a scope for mytenant-admin.sharepoint.com and got a corresponding error.
As working on the CLI for M365, I tried to use some Tenant REST API methods (such as restoring / removing deleted sites), but as it returns SpoOperation objects that doesn't give any identifier to check the status of the execution, I eventually had to use CSOM (eg client.svc) instead.
So to answer @mplwork, the only thing I noticed is that you have to replace double quotes by simple quotes in the URL of the query. Instead of the error you described (which says your query is invalid), you'll have an Microsoft.Online.SharePoint.Common.SpoException 500 error message : _The site Uri provided is null._ Don't know what to do with that anyway and what's missing since it's not documented.
My suggestion would be to use CSOM approach and to give you another implementation, I suggest you to have a look at what has been coded for the spo site classic set command. The source code for that is here.
So, to init the implementation in PnP JS, a first approach would be to reuse the commands used in the CLI, based on CSOM, that we are sure are working. Here's a list:
LockState, AllowEditing, Sharing Capability,..)OneDriveStorageQuota, UserVoiceForFeedbackEnabled,...)What do you think about that?
I would prefer strongly we not add CSOM calls to PnPjs.
Ok, so if we keep in mind the approach by REST API, there a many operations that are available. Below a list of endpoints with which we could start:
_api/Microsoft.Online.SharePoint.TenantManagement.Office365Tenant_api/Microsoft.Online.SharePoint.TenantAdministration.SiteProperties_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant_api/Microsoft.Online.SharePoint.TenantManagement.Office365TenantThe complexity is about making some queries to work, as they're not documented and when executing them, I got error responses without details like the one mentioned in my previous comment.
Does anyone have detailed info about those APIs or how to query them correctly ?
@michaelmaillot - I don't have details off the top of my head but when I have some time I can investigate, though unsure how soon that will be. Welcome other's input as well
Most helpful comment
Def possible - been a bit since I checked what is actually exposed via REST from that API. I think re-checking that would be a first step to see what we could effectively surface.