Hello,
I am developing a Canvas PowerApps that creates Teams in MS Teams and adds members and owners. I can already create the Teams, and I have two collections that have users Ids. My problem is how to add those users to the newly created Team. I am using the "MicrosoftTeams.CreateATeam" action, which in theory returns CreateATeamResponse that contains a newTeamId value.
The code below shows the intended function. I am not sure whether the way I am trying to set a global variable "NewID" is correct or whether the ForAll function actually works. I haven't been able to test those bits because I am getting an error in the create a team bit.
Set(NewID,MicrosoftTeams.CreateATeam(
NewProjectName,
NewProjectDescription,
{visibility:"Private"}).newTeamId);
ForAll(
OwenerList,
MicrosoftTeams.AddMemberToTeam(NewID,UserId,{owner:true}));
ForAll(
MemberList,
MicrosoftTeams.AddMemberToTeam(NewID,UserId,{owner:false}));
After I run the app, I am getting an error that says:
MicrosoftTeams.CreateATeam failed: The data returned in the response is invalid. Response data should be a valid JSON object.
The MicrosoftTeams.CreateATeam function actually works, disregarding the error. The new Team gets created in MS Teams, and I am the owner. However, I think that, due to the error, the function is not returning the new Id, which prevents me from testing the rest of my code. I already isolated the code and run a play canvas with a button that only creates the new Team:
MicrosoftTeams.CreateATeam(
NewProjectName,
NewProjectDescription,
{visibility:"Private"})
However, the error persist. This error only shows after running the app. Before, it doesn't show the red underlines on me code:
Few reasons are under my radar, but I am an amateur when it comes to coding and, this is my first ever PowerApps application, so not sure I am on the right track or whether I am making a rookie mistake.
Anyway, feel free to ask additional questions and constructively criticise my coding.
Thanks in advance.
@ooramirez just tested the MS Teams connector in power Apps, seems like some issue with it.
I was able to create the MS Teams successfully but later it threw error.
I also found this article where others are facing same issue. you can create MS Teams using Power Automate, simple and stable.
https://powerusers.microsoft.com/t5/Building-Power-Apps/Error-when-creating-a-MS-Team/td-p/665016
Create and add users in MS Teams using - Power Automate - https://www.salestim.com/power-automate-how-to-create-teams-from-microsoft-teams-template/
Create and Add users in MS teams using - Graph API and Power Automate - https://powerusers.microsoft.com/t5/Power-Automate-Community-Blog/How-to-provision-team-with-Flow/ba...
Please thumbs up if my reply was helpful.
The MSTeams Connector throws this issue for creating a new Team. The team is created but the error is a pain and you don't get back the Team Identifier.
Hi
Appreciate this post is fairly old but I ran into the same issue and while I haven't come up with an elegant solution I did come up with a workaround. My scenario is very similar in that I want to automatically create a new team and add one or more members. My workaround is as follows:
MicrosoftTeams.CreateATeam(
txtMSTeamsName.Text,
"Automatically created via Project Controls Power Apps app"
);
MicrosoftTeams.AddMemberToTeam(
First(Filter(MicrosoftTeams.GetAllTeams().value, displayName = txtMSTeamsName.Text)).id,
"5e79f34a-723d-4b65-8198-c8d66925d8fa",
{owner: true}
)
The txtMSTeamsName contains the name of the team to be created.
Hopefully, this will help someone.