cli-microsoft365: Bug report: Impossible to create team when using application permissions

Priority

(Low) Something is a little off

Description

It is currently impossible to create a team when using application permissions. This is due to the application permissions request expecting a members property in the request body, and we currently do not demand this.

More information can be found on this URL: https://learn.microsoft.com/en-us/graph/api/team-post?view=graph-rest-1.0&tabs=http#examples

Steps to reproduce

  1. Login using application permissions
  2. Execute m365 teams team add --name 'TEST' --description 'TEST'

Expected results

Team being created or a prompt for members

Actual results

Error: Request failed with status code 400

Diagnostics

Request error:
{
  "url": "https://graph.microsoft.com/v1.0/teams",
  "status": 400,
  "statusText": "Bad Request",
  "headers": {
    "transfer-encoding": "chunked",
    "content-type": "application/json",
    "vary": "Accept-Encoding",
    "strict-transport-security": "max-age=31536000",
    "request-id": "51e35905-5bb0-4c3b-8616-df164c8099e3",
    "client-request-id": "51e35905-5bb0-4c3b-8616-df164c8099e3",
    "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"North Europe\",\"Slice\":\"E\",\"Ring\":\"4\",\"ScaleUnit\":\"003\",\"RoleInstance\":\"DB1PEPF0002D0AB\"}}",
    "date": "Tue, 23 May 2023 09:52:51 GMT",
    "connection": "close"
  }
}

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 25 (25 by maintainers)

Commits related to this issue

Most upvoted comments

Let’s do that. And ownerEmails?

Could include that one as well, so do we agree to add the options below?

  • ownerUserNames
  • ownerIds
  • ownerEmails
  • memberUserNames
  • memberIds
  • memberEmails

That’s a bummer! I think we should stick to the spec and update the team members afterward.

Sure thing. So I create the team using the first user passed in either one of the owner options and then afterwards patch the team?

Can I restart working on this one?

That’s a bummer! I think we should stick to the spec and update the team members afterward.

Any updates regarding this issue?

I don’t know. 😊 Consistency could be an argument. For some commands this won’t be that simple, e.g. for aad user get, how do you call an option that accepts both the ID and UPN? Also, some commands accept ID, UPN, and Email, in that case, we cannot tell whether an Email is UPN or a mail.

So

  • in delegated mode, when you don’t specify --owners, it will add the signed in user.
  • in delegated mode, when you specify --owners, it will add the owners, but not the signed in user if he isn’t part of the owners string.
  • in app only mode, --owners is required.

?

Yeah, a team needs at least an owner indeed. We could also add a --memberUserNames option and allow a comma separated string of UPNs… (just like the chat message send command)

I’d say we start with just specifying a single owner, to at least get this command to work, and we can extend this command in general in the future I believe.

I suggest that we decide now if we’d like to support a single- or multiple users, so that we can avoid breaking changes later on. If I for example look at spo site add and aad o365group add, we support --owners [owners]. I suggest we use the same convention here for consistency.

Yeah, a team needs at least an owner indeed. We could also add a --memberUserNames option and allow a comma separated string of UPNs… (just like the chat message send command)

Thanks, @MathijsVerbeeck for rising this 👍. We will try to recheck this one ASAP