Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Teams Backend stopped working #244

Closed
golubenkoff opened this issue May 13, 2022 · 5 comments
Closed

Teams Backend stopped working #244

golubenkoff opened this issue May 13, 2022 · 5 comments

Comments

@golubenkoff
Copy link

Expected Behavior

Connected to Teams and Members Loaded

Current Behavior

Message":"Error authenticating to Teams"
Data":{"CommandName":"Invoke-RestMethod"
Message":"The remote server returned an error: (404) Not Found."
RequestUri":"https://webchat.botframework.com/v3/conversations/19:[email protected]/members/"

Possible Solution

I think it is connected with API deprecation - is it possible to somehow quickly fix this?
See url below with possible changes

Steps to Reproduce (for bugs)

Check this:
https://docs.microsoft.com/en-us/microsoftteams/platform/resources/team-chat-member-api-changes
https://docs.microsoft.com/en-us/microsoftteams/platform/bots/how-to/get-teams-context?tabs=json#tabpanel_CeZOj-G++Q_json

I think issue here:
[void]LoadUsers()
Line 9615: $uri = "$($this.ServiceUrl)v3/conversations/$($this.TeamId)/members/"

  • here should be new paged users load

Context

Your Environment

  • Module version used: ModuleVersion = '0.14.0'
  • Operating System and PowerShell version: PowerShell 5.1, Windows Server 2019 Datacenter
@golubenkoff
Copy link
Author

Managed to fix this via:
TeamsBackend.ps1

Here:
# Populate the list of users the team
[void]LoadUsers()

Replace this:

$this.LogDebug('Getting Teams users')

$uri = "$($this.ServiceUrl)v3/conversations/$($this.TeamId)/members/"
$headers = @{
    Authorization = "Bearer $($this.Connection._AccessTokenInfo.access_token)"
}
$members = Invoke-RestMethod -Uri $uri -Headers $headers
$this.LogDebug('Finished getting Teams users')

To this:

$this.LogDebug('Getting Teams users')

$uri = "$($this.ServiceUrl)v3/conversations/$($this.TeamId)/pagedmembers?pageSize=500"
$headers = @{
   Authorization = "Bearer $($this.Connection._AccessTokenInfo.access_token)"
}

$members = @()
do {
   $Results = ''
   $StatusCode = ''
   do {
       try {
           $Results = Invoke-RestMethod -Headers $headers -Uri $Uri -UseBasicParsing -Method 'GET' -ContentType 'application/json'

           $StatusCode = $Results.StatusCode
       } catch {
           $StatusCode = $_.Exception.Response.StatusCode.value__

           if ($StatusCode -eq 429) {
               $this.LogDebug('Got throttled by Microsoft. Sleeping for 45 seconds...')
               Start-Sleep -Seconds 45
           } else {
               $this.LogDebug("Error Populating the list of users for the team: $($_.Exception.Message)")
           }
       }
   } while ($StatusCode -eq 429)
   if ($Results.continuationToken) {
       $uri = "$($this.ServiceUrl)v3/conversations/$($this.TeamId)/pagedmembers?pageSize=500&continuationToken=$($Results.continuationToken)"
       $members += $Results.members
   } else {
       $members += $Results.members
   }
} while ($Results.continuationToken)
$this.LogDebug('Finished getting Teams users') 

Checked on my environment - with 8000+ users - all is OK.

@golubenkoff
Copy link
Author

golubenkoff commented May 13, 2022

Check Fixed Here:
golubenkoff@787fafc

@devblackops
Copy link
Member

@golubenkoff Mind doing a PR with the fix?

@golubenkoff
Copy link
Author

#248 (comment)

@mengdahuang
Copy link

@golubenkoff
Hi, golubenkoff could you tell us does the poshbot (teams bot) still working normal or not? i got the same issue PoshBot not receiving webhook information in Teams console,
hope you can help us. thanks a lot, have a nice day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants