Copilot for Microsoft 365 Tech Accelerator
Feb 28 2024 07:00 AM - Feb 29 2024 10:30 AM (PST)
Microsoft Tech Community

Connecting SharePoint Online Teams Site With Microsoft teams team Programmatically

Copper Contributor



Recently I had a requirement to create a SharePoint online teams site and, connect created teams site to Microsoft teams (as a group.) So I have gone through and I found out that using REST API I can create a SP Online Teams site via "/_api/GroupSiteManager/CreateGroupEx" by passing the relevant JSON. I have successfully done it.

Then my second requirement was to connect created site into Microsoft Teams. I can do it manually inside of the created site, by clicking "Connect to teams" link. I wanted that to be programmatically. I couldn't find any API end point related to that and what I did was opened my network tab and checked the request and payload. Flowing attached is the image of the payload. 



So simply what I did was called the endpoint "/_api/GroupSiteManager/PinToTeam" and Sent the relevant JSON. And that point I am getting an error as following: 


{"error":{"code":"-1, Microsoft.Data.OData.ODataException","message":{"lang":"en-US","value":"The property '__metadata' does not exist on type 'Microsoft.SharePoint.Portal.PinToTeamParams'. Make sure to only use property names that are defined by the type."}}}


When I searched I couldn't find any related to "/_api/GroupSiteManager/PinToTeam". Could someone please help me to resolve this error?





0 Replies