全て
| カテゴリ未分類
| 通常
| 数学
| 投資
| 副業
| 転職・就職
| ブログ
| 株Stock
| VBA
| SharePoint
| REST API
| RenderListDataAsStream
| PowerAutomateDesktop
| Graph API
| PowerApps
| PowerAutomate
| PowerFx
| OfficeScriptオフィススクリプト
| PowerAutomate日時Excel日時相互関係
| PowerShell
| Dataverse
| UiPath
| OneDrive
| LINQ
| VB.NET
| C#.NET
| WPFC#.NET
| Git
カテゴリ:Graph API
# Microsoft Graph SDK のインストール Install-Module -Name Microsoft.Graph.Teams # アプリケーションの認証情報 $clientId = "YOUR_CLIENT_ID" $clientSecret = "YOUR_CLIENT_SECRET" $tenantId = "YOUR_TENANT_ID" # アクセストークンの取得 $accessToken = Get-MgAccessToken -ClientId $clientId -ClientSecret $clientSecret -TenantId $tenantId if (-not [string]::IsNullOrEmpty($accessToken)) { Write-Host "Access Token: $accessToken" # チームの ID およびチャンネルの ID $teamId = "TEAM_ID" $channelId = "CHANNEL_ID" # 投稿するメッセージの本文(HTML 形式) $htmlMessageBody = "<html><body><h1>Hello, World!</h1><p>This is a test message in HTML format.</p></body></html>" # メッセージの作成 $messageBody = @{ contentType = "html" content = $htmlMessageBody } | ConvertTo-Json $postMessageUrl = "https://graph.microsoft.com/v1.0/teams/$teamId/channels/$channelId/messages" $postMessageResponse = Invoke-RestMethod -Uri $postMessageUrl -Method Post -Headers @{ Authorization = "Bearer $accessToken" 'Content-Type' = 'application/json' } -Body $messageBody if ($postMessageResponse) { Write-Host "Message posted successfully. Message ID: $($postMessageResponse.id)" } else { Write-Host "Failed to post message." } } else { Write-Host "Failed to retrieve access token." } お気に入りの記事を「いいね!」で応援しよう
Last updated
2024.02.26 03:27:16
[Graph API] カテゴリの最新記事
|