Update Site Sharing Capability with Flow > How to use "admin.sp.com/_api/Tenant/Sites/Update"

%3CLINGO-SUB%20id%3D%22lingo-sub-1608741%22%20slang%3D%22en-US%22%3EUpdate%20Site%20Sharing%20Capability%20with%20Flow%20%26gt%3B%20How%20to%20use%20%22admin.sp.com%2F_api%2FTenant%2FSites%2FUpdate%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1608741%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAs%20admin%2C%20I%20need%20to%20update%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsharepoint%2Fchange-external-sharing-site%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Esharing%20capability%3C%2FA%3E%26nbsp%3Bof%20a%20SharePoint%20site%20using%20Power%20Automate.%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22external-sharing-site%22%20style%3D%22width%3A%20378px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F214377iEC2EC9B5B480C8B5%2Fimage-dimensions%2F378x293%3Fv%3D1.0%22%20width%3D%22378%22%20height%3D%22293%22%20title%3D%22external-sharing-site%22%20alt%3D%22external-sharing-site%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20have%20not%20figured%20out%20a%20way%20of%20doing%20this%20with%20%3CEM%3EGraph%20API%3C%2FEM%3E%20so%20I%20am%20now%20trying%20with%20%3CEM%3ESharePoint%20REST%20API%3C%2FEM%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUsing%2C%20%22%3CEM%3ESend%20an%20HTTP%20request%20to%20SharePoint%3C%2FEM%3E%22%2C%20I%20can%20read%20the%20current%20setting%20on%20%3CA%20href%3D%22https%3A%2F%2Fmytenant-admin.sharepoint.com%2F_api%2FMicrosoft.Online.SharePoint.TenantAdministration.Tenant%2FSites('siteId')%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fmytenant-admin.sharepoint.com%2F_api%2FMicrosoft.Online.SharePoint.TenantAdministration.Tenant%2FSites('siteId')%2F%3C%2FA%3E%26nbsp%3Bbut%20I%20can't%20use%20the%26nbsp%3B%3CEM%3EUpdate%3C%2FEM%3E%20method%20with%20POST.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20anyone%20know%20how%20to%20do%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1795561%22%20slang%3D%22en-US%22%3ERe%3A%20Update%20Site%20Sharing%20Capability%20with%20Flow%20%26gt%3B%20How%20to%20use%20%22admin.sp.com%2F_api%2FTenant%2FSites%2FUp%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1795561%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F769402%22%20target%3D%22_blank%22%3E%40alextest%3C%2FA%3E%26nbsp%3Bhow%20about%20PUT%20or%2C%20probably%20better%20use%20PATCH%3F%20Please%20try%20on%20non-production%20first.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Hello everyone,

 

As admin, I need to update the sharing capability of a SharePoint site using Power Automate.

external-sharing-site

I have not figured out a way of doing this with Graph API so I am now trying with SharePoint REST API.

 

Using, "Send an HTTP request to SharePoint", I can read the current setting on https://mytenant-admin.sharepoint.com/_api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/S... but I can't use the Update method with POST.

 

Does anyone know how to do this?

 

Thanks !

2 Replies

@alextest how about PUT or, probably better use PATCH? Please try on non-production first.

In case someone looking for a solution, this is how I manage to solve this:

you need to use admin API, the URL of the admin API is 

https://{tenant name}-admin.sharepoint.com/

you will need the site ID of the site that you want to change the sharing setting.

in your power automate add a new 'Send HTTP request to SharePoint'

 

Site address: https://{tenant name}-admin.sharepoint.com/

Method: Post

Uri: _api/Microsoft.Online.SharePoint.TenantAdministration.Tenant/Sites('{Site ID}')

Headers:

  • accept  :   application/json;odata=verbose
  • content-type:    application/json;odata=verbose
  • X-HTTP-Method:     MERGE

Body:

{
"__metadata": {
"type": "Microsoft.Online.SharePoint.TenantAdministration.SiteProperties"
},
"SharingCapability": 1
}

Matt_majedi_0-1623753864470.png