Async Function AssignRoleToItem(siteUrl As String, username As String, password As String, listName As String, itemId As Integer, groupName As String) As Task
Dim credentials As String = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{username}:{password}"))
' グループ ID を取得
Dim groupId As Integer = Await GetGroupId(siteUrl, credentials, groupName)
If groupId <> -1 Then
' リストアイテムに対して権限を設定する
Dim endpointUrl As String = $"{siteUrl}/_api/web/lists/getbytitle('{listName}')/items({itemId})/roleassignments/addroleassignment(principalid={groupId}, roledefid=1073741827)"
Using client As New HttpClient()
client.DefaultRequestHeaders.Authorization = New System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials)