title: Post Chat message using Graphapi via Powershell using Delegate Grant type
body: <p>Post Chat message using Graphapi via Powershell using Delegate Grant type using password grant</p>
  <p>#Group chat Message</p>
  <pre><code>$granttype = 'password'
  $tenantID = '695bbc7172e0'
  $scope = 'https://graph.microsoft.com/.default'
  $clientSecret = (ConvertTo-SecureString &quot;O4UN4ndB&quot; -AsPlainText -Force )
  $cred = Import-Clixml C:\temp\credentials.xml
  $redirectUri = &quot;https://testexchangeewsdelegate.com&quot;
  # Construct URI
  $uri = &quot;https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token&quot;
  
  # Construct Body
  
  $body = @{
  clientId = &quot;0e003e593d&quot;
  scope         = $scope
  grant_type    = $granttype
  username      = $cred.UserName
  password      = $cred.GetNetworkCredential().password
  }
  
  $TokenResponses = Invoke-RestMethod -Uri &quot;https://login.microsoftonline.com/$TenantName/oauth2/v2.0/token&quot; -Method POST -Body $ReqTokenBody
  $apiUrl = 'https://graph.microsoft.com/v1.0/chats/19:987345050c22c8369df1a6@thread.v2'
  Invoke-RestMethod -Headers @{Authorization = &quot;Bearer $($Tokenresponses.access_token)&quot;} -Uri $apiUrl -Method Get -ContentType &quot;application/x-www-form-urlencoded&quot;
  
  $apiUrl1 = 'https://graph.microsoft.com/v1.0/chats/19:987345050c22c8369df1a6@thread.v2/messages'
  
  $params = @{ 
  Body = @{ Content = &quot;Hello World&quot;} }
  
  $bodyJSON = $params| ConvertTo-Json
  
  Invoke-RestMethod -Headers @{Authorization = &quot;Bearer $($Tokenresponses.access_token)&quot;} -Uri $apiUrl1 -Method Post -Body $bodyJSON -ContentType 'application/json'
  </code></pre>
  <p>Help me to update group chat post using PowerShell via graph api</p>