Forum Discussion

alextest's avatar
alextest
Copper Contributor
Aug 24, 2020

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

Hello everyone,

 

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

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/Sites('siteId')/ but I can't use the Update method with POST.

 

Does anyone know how to do this?

 

Thanks !

  • Matt_majedi's avatar
    Matt_majedi
    Copper Contributor

    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
    }

     

     

    • Aysani's avatar
      Aysani
      Copper Contributor
      Thank you for sharing! great find!
      • OmarSeri Replace {tenant} in URL with the actual name of your tenant where you are creating the flow. For example: 

         

        https://contoso-admin.sharepoint.com

         

        And add it as a custom value like: 


        Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.

        For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs

Resources