Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Teams access policy - New-CsApplicationAccessPolicy returns 404

I am trying to use the Microsoft Graph API to create OnlineMeetings here https://learn.microsoft.com/en-us/graph/api/application-post-onlinemeetings?view=graph-rest-1.0&tabs=http

But when configuring application access policy as instructed here:

https://learn.microsoft.com/en-us/graph/cloud-communication-online-meeting-application-access-policy

We got a 404 error:

New-CsApplicationAccessPolicy -Identity OnlineMeetings-Link -AppIds "xxx-xxx-xxx" -Description "xxxx Local"      

Get-CsOnlineSession: /Users/xxx/.local/share/powershell/Modules/MicrosoftTeams/2.3.1/netcoreapp3.1/SfBORemotePowershellModule.psm1:63

Line |
  63 |      $remoteSession = & (Get-CsOnlineSessionCommand)
     |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The remote server returned an error: (404) Not Found.

Invoke-Command: /Users/xxx/.local/share/powershell/Modules/MicrosoftTeams/2.3.1/netcoreapp3.1/SfBORemotePowershellModule.psm1:22959

 Line |
22959 |  …    -Session (Get-PSImplicitRemotingSession -CommandName 'New-CsApplic …
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Cannot validate argument on parameter 'Session'. The argument
      | is null or empty. Provide an argument that is not null or
      | empty, and then try the command again.

I am an admin of the work/school account, and I have done all setup prerequisites:

https://learn.microsoft.com/en-us/microsoftteams/teams-powershell-install https://learn.microsoft.com/en-us/microsoft-365/enterprise/manage-skype-for-business-online-with-microsoft-365-powershell?view=o365-worldwide

I have all admin permissions to perform PowerShell cmdlet:

Microsoft Permissions

Environment:

PowerShell version: 7.1.3, installed with homebrew
MicrosoftTeams module version: 2.3.1
OS: Mac Mojave 10.14.6

I have no firewall, VPN/proxy enabled. The same issue happens when I tried it in the default PowerShell of Windows 10 VM on VirtualBox.

What should I do to get around this issue?

like image 495
Hoang Phan Avatar asked Jul 04 '21 23:07

Hoang Phan


2 Answers

Looking at the error, the following could be the reasons

  • Incorrect App ID or App ID does not exist
  • Session parameter is empty

Request you to please check again and see if it works.

like image 87
Meghana-MSFT Avatar answered Oct 23 '22 18:10

Meghana-MSFT


Upgrade the microsoft teams powershell module to 2.4.0 which is the latest version.

  1. Connect-MicrosoftTeams #Enter global Administrator account credential and make sure that you see Admin account details in connection output.

  2. Now execute the New-CsApplicationAccessPolicy

New-CsApplicationAccessPolicy -Identity OnlineMeetings-Link -AppIds "applicationID" -Description "description here".

enter image description here

enter image description here

To create a online meeting on behalf of a user in Microsoft Teams using Graph API there are two possiblities :

  1. Create an event in teams by doing a Post https://graph.microsoft.com/v1.0/me/events and add properties "isOnlineMeeting":True and "onlineMeetingProvider":"teamsForBusiness" in the Body of the request.

    Sample:

    POST https://graph.microsoft.com/v1.0/me/events
Prefer: outlook.timezone="Pacific Standard Time"
Content-type: application/json

{
  "subject": "Meeting for New Member",
  "body": {
    "contentType": "HTML",
    "content": "Hello Team"
  },
  "start": {
      "dateTime": "2021-07-09T15:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "end": {
      "dateTime": "2021-07-09T15:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "location":{
      "displayName":"Virtual"
  },
  "attendees": [
    {
      "emailAddress": {
        "address":"[email protected]",
        "name": "User"
      },
      "type": "required"
    }
  ],
  "allowNewTimeProposals": true,
  "isOnlineMeeting": true,
  "onlineMeetingProvider": "teamsForBusiness"
}

If you use the above method then you can invite other users and the meeting appears in the calendar of the organizer.

Reference:

Create Event - Microsoft Graph v1.0 | Microsoft Docs

  1. Create Online Meeting

    You can directly create meeting by doing a post to POST https://graph.microsoft.com/v1.0/me/onlineMeetings

In the above method no invitations are sent and the meeting does not appear in the calendar of the organizer. You would need alternative means to distribute the dial-in link, etc.

Sample:

POST https://graph.microsoft.com/v1.0/me/onlineMeetings
Content-Type: application/json

{
  "startDateTime":"2021-07-09T14:30:34.2444915-05:30",
  "endDateTime":"2021-07-09T15:00:34.2464912-05:30",
  "subject":"User Token Meeting"
}

Reference:

Create onlineMeeting - Microsoft Graph v1.0 | Microsoft Docs

like image 24
AnsumanBal-MT Avatar answered Oct 23 '22 19:10

AnsumanBal-MT