cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ooramirez
Regular Visitor

Create a Team in MS teams and adding Team members (Return Value Error)

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:

 

chrome_f8llOSQYXc.png

 

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. 

 

  • I read something about Asynchronous function. I have no idea whether it is relevant here, but I know that the new Id would need to come from Teams, meaning that my app might not be waiting for the response (???).
  • The function is broken, and there is no return value. I notice that there is barely any comments or post using this function. Not sure it has been tested enough.

Anyway, feel free to ask additional questions and constructively criticise my coding.

 

Thanks in advance.

3 REPLIES 3
vermaaman
Resolver I
Resolver I

@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. 

vermaaman_0-1635397843944.png

 

vermaaman_1-1635397873067.png

 

 

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.

paulbeck1
Advocate I
Advocate I

CreaeATeam-Error.PNG

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.

Anonymous
Not applicable

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.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,212)