更新プログラム チャネル
[アーティクル]
02/14/2022
3 人の共同作成者
この記事の内容
名前空間: microsoft.graph
重要
Microsoft Graph のバージョンの /beta API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 API が v1.0 で使用できるかどうかを確認するには、 バージョン セレクターを使用します。
指定したチャネルのプロパティを更新 します 。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可 」を参照してください。
アクセス許可の種類
アクセス許可 (特権の小さいものから大きいものへ)
委任 (職場または学校のアカウント)
ChannelSettings.ReadWrite.All, Group.ReadWrite.All , Directory.ReadWrite.All
委任 (個人用 Microsoft アカウント)
サポートされていません。
アプリケーション
ChannelSettings.ReadWrite.Group , ChannelSettings.ReadWrite.All, Group.ReadWrite.All *, Directory.ReadWrite.All**
注 :
** でマークされたアクセス許可は、下位互換性のためにのみサポートされます。 前の表に記載されている別のアクセス許可を使用するようにソリューションを更新し、今後これらのアクセス許可を使用しないようにすることをお勧めします。
注 : この API は、管理者のアクセス許可をサポートします。グローバル管理者と Microsoft Teams サービス管理者は、メンバーではないチームにアクセスできます。
HTTP 要求
PATCH /teams/{team-id}/channels/{channel-id}
ヘッダー
値
Authorization
ベアラー {token}。必須。
Content-Type
application/json. Required.
要求本文
要求本文で、チャンネル オブジェクトの JSON 表記を指定します。
注: 既存のチャネルの membershipType 値を更新することはできません。
応答
成功した場合、このメソッドは 204 No Content 応答コードを返します。
例
例 1: チャネルの更新
要求
以下は、要求の例です。
PATCH https://graph.microsoft.com/beta/teams/893075dd-2487-4122-925f-022c42e20265/channels/19:561fbdbbfca848a484f0a6f00ce9dbbd@thread.tacv2
応答
以下は、応答の例です。
HTTP/1.1 204 No Content
例 2: モデレート設定でチャネルを更新する
要求
次の例は、チャネルのモデレート設定を 更新する要求 を示しています。 この操作は、チームの所有者だけが実行できます。
PATCH https://graph.microsoft.com/beta/teams/893075dd-2487-4122-925f-022c42e20265/channels/19:561fbdbbfca848a484f0a6f00ce9dbbd@thread.tacv2
Content-type: application/json
{
"displayName": "UpdateChannelModeration",
"description": "Update channel moderation.",
"moderationSettings": {
"userNewMessageRestriction": "moderators",
"replyRestriction": "everyone",
"allowNewMessageFromBots": true,
"allowNewMessageFromConnectors": true
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var channel = new Channel
{
DisplayName = "UpdateChannelModeration",
Description = "Update channel moderation.",
ModerationSettings = new ChannelModerationSettings
{
UserNewMessageRestriction = UserNewMessageRestriction.Moderators,
ReplyRestriction = ReplyRestriction.Everyone,
AllowNewMessageFromBots = true,
AllowNewMessageFromConnectors = true
}
};
await graphClient.Teams["{team-id}"].Channels["{channel-id}"]
.Request()
.UpdateAsync(channel);
const options = {
authProvider,
};
const client = Client.init(options);
const channel = {
displayName: 'UpdateChannelModeration',
description: 'Update channel moderation.',
moderationSettings: {
userNewMessageRestriction: 'moderators',
replyRestriction: 'everyone',
allowNewMessageFromBots: true,
allowNewMessageFromConnectors: true
}
};
await client.api('/teams/893075dd-2487-4122-925f-022c42e20265/channels/19:561fbdbbfca848a484f0a6f00ce9dbbd@thread.tacv2')
.version('beta')
.update(channel);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/teams/893075dd-2487-4122-925f-022c42e20265/channels/19:561fbdbbfca848a484f0a6f00ce9dbbd@thread.tacv2"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphChannel *channel = [[MSGraphChannel alloc] init];
[channel setDisplayName:@"UpdateChannelModeration"];
[channel setDescription:@"Update channel moderation."];
MSGraphChannelModerationSettings *moderationSettings = [[MSGraphChannelModerationSettings alloc] init];
[moderationSettings setUserNewMessageRestriction: [MSGraphUserNewMessageRestriction moderators]];
[moderationSettings setReplyRestriction: [MSGraphReplyRestriction everyone]];
[moderationSettings setAllowNewMessageFromBots: true];
[moderationSettings setAllowNewMessageFromConnectors: true];
[channel setModerationSettings:moderationSettings];
NSError *error;
NSData *channelData = [channel getSerializedDataWithError:&error];
[urlRequest setHTTPBody:channelData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
Channel channel = new Channel();
channel.displayName = "UpdateChannelModeration";
channel.description = "Update channel moderation.";
ChannelModerationSettings moderationSettings = new ChannelModerationSettings();
moderationSettings.userNewMessageRestriction = UserNewMessageRestriction.MODERATORS;
moderationSettings.replyRestriction = ReplyRestriction.EVERYONE;
moderationSettings.allowNewMessageFromBots = true;
moderationSettings.allowNewMessageFromConnectors = true;
channel.moderationSettings = moderationSettings;
graphClient.teams("893075dd-2487-4122-925f-022c42e20265").channels("19:561fbdbbfca848a484f0a6f00ce9dbbd@thread.tacv2")
.buildRequest()
.patch(channel);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewChannel()
displayName := "UpdateChannelModeration"
requestBody.SetDisplayName(&displayName)
description := "Update channel moderation."
requestBody.SetDescription(&description)
moderationSettings := msgraphsdk.NewChannelModerationSettings()
requestBody.SetModerationSettings(moderationSettings)
userNewMessageRestriction := "moderators"
moderationSettings.SetUserNewMessageRestriction(&userNewMessageRestriction)
replyRestriction := "everyone"
moderationSettings.SetReplyRestriction(&replyRestriction)
allowNewMessageFromBots := true
moderationSettings.SetAllowNewMessageFromBots(&allowNewMessageFromBots)
allowNewMessageFromConnectors := true
moderationSettings.SetAllowNewMessageFromConnectors(&allowNewMessageFromConnectors)
teamId := "team-id"
channelId := "channel-id"
graphClient.TeamsById(&teamId).ChannelsById(&channelId).Patch(requestBody)
Import-Module Microsoft.Graph.Teams
$params = @{
DisplayName = "UpdateChannelModeration"
Description = "Update channel moderation."
ModerationSettings = @{
UserNewMessageRestriction = "moderators"
ReplyRestriction = "everyone"
AllowNewMessageFromBots = $true
AllowNewMessageFromConnectors = $true
}
}
Update-MgTeamChannel -TeamId $teamId -ChannelId $channelId -BodyParameter $params
応答
以下は、応答の例です。
HTTP/1.1 204 No Content