会話スレッドを作成する
[アーティクル]
05/05/2022
3 人の共同作成者
この記事の内容
名前空間: microsoft.graph
最初にスレッドを作成して、新しいグループ会話を開始します。
グループには、新しい会話、会話スレッド、および投稿が作成されます。スレッドに返信 または 投稿に返信 を使い、そのスレッドへの投稿を続けます。
注:既存の会話内に新しいスレッドを開始する こともできます。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可 」を参照してください。
アクセス許可の種類
アクセス許可 (特権の小さいものから大きいものへ)
委任 (職場または学校のアカウント)
Group.ReadWrite.All
委任 (個人用 Microsoft アカウント)
サポートされていません。
アプリケーション
サポートされていません。
HTTP 要求
POST /groups/{id}/threads
ヘッダー
値
Authorization
ベアラー {token}。必須。
Content-Type
application/json
要求本文
要求の本文に、投稿 を含むconversationThread オブジェクトの JSON 表記を指定します。
応答
成功した場合、このメソッドは 201 Created 応答コードと、応答本文で conversationThread オブジェクトを返します。
例
要求
要求の例を次に示します。
POST https://graph.microsoft.com/v1.0/groups/{id}/threads
Content-type: application/json
{
"topic": "New Conversation Thread Topic",
"posts": [{
"body": {
"contentType": "html",
"content": "this is body content"
},
"newParticipants": [{
"emailAddress": {
"name": "Alex Darrow",
"address": "alexd@contoso.com"
}
}]
}]
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var conversationThread = new ConversationThread
{
Topic = "New Conversation Thread Topic",
Posts = new ConversationThreadPostsCollectionPage()
{
new Post
{
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "this is body content"
},
NewParticipants = new List<Recipient>()
{
new Recipient
{
EmailAddress = new EmailAddress
{
Name = "Alex Darrow",
Address = "alexd@contoso.com"
}
}
}
}
}
};
await graphClient.Groups["{group-id}"].Threads
.Request()
.AddAsync(conversationThread);
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var conversationThread = new ConversationThread
{
Topic = "New Conversation Thread Topic",
Posts = new ConversationThreadPostsCollectionPage()
{
new Post
{
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "this is body content"
},
NewParticipants = new List<Recipient>()
{
new Recipient
{
EmailAddress = new EmailAddress
{
Name = "Alex Darrow",
Address = "alexd@contoso.com"
}
}
}
}
}
};
await graphClient.Groups["{group-id}"].Threads
.Request()
.AddAsync(conversationThread);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
const options = {
authProvider,
};
const client = Client.init(options);
const conversationThread = {
topic: 'New Conversation Thread Topic',
posts: [{
body: {
contentType: 'html',
content: 'this is body content'
},
newParticipants: [{
emailAddress: {
name: 'Alex Darrow',
address: 'alexd@contoso.com'
}
}]
}]
};
await client.api('/groups/{id}/threads')
.post(conversationThread);
const options = {
authProvider,
};
const client = Client.init(options);
const conversationThread = {
topic: 'New Conversation Thread Topic',
posts: [{
body: {
contentType: 'html',
content: 'this is body content'
},
newParticipants: [{
emailAddress: {
name: 'Alex Darrow',
address: 'alexd@contoso.com'
}
}]
}]
};
await client.api('/groups/{id}/threads')
.post(conversationThread);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/threads"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphConversationThread *conversationThread = [[MSGraphConversationThread alloc] init];
[conversationThread setTopic:@"New Conversation Thread Topic"];
NSMutableArray *postsList = [[NSMutableArray alloc] init];
MSGraphPost *posts = [[MSGraphPost alloc] init];
MSGraphItemBody *body = [[MSGraphItemBody alloc] init];
[body setContentType: [MSGraphBodyType html]];
[body setContent:@"this is body content"];
[posts setBody:body];
NSMutableArray *newParticipantsList = [[NSMutableArray alloc] init];
MSGraphRecipient *newParticipants = [[MSGraphRecipient alloc] init];
MSGraphEmailAddress *emailAddress = [[MSGraphEmailAddress alloc] init];
[emailAddress setName:@"Alex Darrow"];
[emailAddress setAddress:@"alexd@contoso.com"];
[newParticipants setEmailAddress:emailAddress];
[newParticipantsList addObject: newParticipants];
[posts setNewParticipants:newParticipantsList];
[postsList addObject: posts];
[conversationThread setPosts:postsList];
NSError *error;
NSData *conversationThreadData = [conversationThread getSerializedDataWithError:&error];
[urlRequest setHTTPBody:conversationThreadData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/groups/{id}/threads"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphConversationThread *conversationThread = [[MSGraphConversationThread alloc] init];
[conversationThread setTopic:@"New Conversation Thread Topic"];
NSMutableArray *postsList = [[NSMutableArray alloc] init];
MSGraphPost *posts = [[MSGraphPost alloc] init];
MSGraphItemBody *body = [[MSGraphItemBody alloc] init];
[body setContentType: [MSGraphBodyType html]];
[body setContent:@"this is body content"];
[posts setBody:body];
NSMutableArray *newParticipantsList = [[NSMutableArray alloc] init];
MSGraphRecipient *newParticipants = [[MSGraphRecipient alloc] init];
MSGraphEmailAddress *emailAddress = [[MSGraphEmailAddress alloc] init];
[emailAddress setName:@"Alex Darrow"];
[emailAddress setAddress:@"alexd@contoso.com"];
[newParticipants setEmailAddress:emailAddress];
[newParticipantsList addObject: newParticipants];
[posts setNewParticipants:newParticipantsList];
[postsList addObject: posts];
[conversationThread setPosts:postsList];
NSError *error;
NSData *conversationThreadData = [conversationThread getSerializedDataWithError:&error];
[urlRequest setHTTPBody:conversationThreadData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
ConversationThread conversationThread = new ConversationThread();
conversationThread.topic = "New Conversation Thread Topic";
LinkedList<Post> postsList = new LinkedList<Post>();
Post posts = new Post();
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "this is body content";
posts.body = body;
LinkedList<Recipient> newParticipantsList = new LinkedList<Recipient>();
Recipient newParticipants = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.name = "Alex Darrow";
emailAddress.address = "alexd@contoso.com";
newParticipants.emailAddress = emailAddress;
newParticipantsList.add(newParticipants);
posts.newParticipants = newParticipantsList;
postsList.add(posts);
PostCollectionResponse postCollectionResponse = new PostCollectionResponse();
postCollectionResponse.value = postsList;
PostCollectionPage postCollectionPage = new PostCollectionPage(postCollectionResponse, null);
conversationThread.posts = postCollectionPage;
graphClient.groups("{id}").threads()
.buildRequest()
.post(conversationThread);
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
ConversationThread conversationThread = new ConversationThread();
conversationThread.topic = "New Conversation Thread Topic";
LinkedList<Post> postsList = new LinkedList<Post>();
Post posts = new Post();
ItemBody body = new ItemBody();
body.contentType = BodyType.HTML;
body.content = "this is body content";
posts.body = body;
LinkedList<Recipient> newParticipantsList = new LinkedList<Recipient>();
Recipient newParticipants = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.name = "Alex Darrow";
emailAddress.address = "alexd@contoso.com";
newParticipants.emailAddress = emailAddress;
newParticipantsList.add(newParticipants);
posts.newParticipants = newParticipantsList;
postsList.add(posts);
PostCollectionResponse postCollectionResponse = new PostCollectionResponse();
postCollectionResponse.value = postsList;
PostCollectionPage postCollectionPage = new PostCollectionPage(postCollectionResponse, null);
conversationThread.posts = postCollectionPage;
graphClient.groups("{id}").threads()
.buildRequest()
.post(conversationThread);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewConversationThread()
topic := "New Conversation Thread Topic"
requestBody.SetTopic(&topic)
requestBody.SetPosts( []Post {
msgraphsdk.NewPost(),
body := msgraphsdk.NewItemBody()
SetBody(body)
contentType := "html"
body.SetContentType(&contentType)
content := "this is body content"
body.SetContent(&content)
SetNewParticipants( []Recipient {
msgraphsdk.NewRecipient(),
SetAdditionalData(map[string]interface{}{
}
}
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).Threads().Post(requestBody)
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewConversationThread()
topic := "New Conversation Thread Topic"
requestBody.SetTopic(&topic)
requestBody.SetPosts( []Post {
msgraphsdk.NewPost(),
body := msgraphsdk.NewItemBody()
SetBody(body)
contentType := "html"
body.SetContentType(&contentType)
content := "this is body content"
body.SetContent(&content)
SetNewParticipants( []Recipient {
msgraphsdk.NewRecipient(),
SetAdditionalData(map[string]interface{}{
}
}
}
groupId := "group-id"
result, err := graphClient.GroupsById(&groupId).Threads().Post(requestBody)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
Import-Module Microsoft.Graph.Groups
$params = @{
Topic = "New Conversation Thread Topic"
Posts = @(
@{
Body = @{
ContentType = "html"
Content = "this is body content"
}
NewParticipants = @(
@{
EmailAddress = @{
Name = "Alex Darrow"
Address = "alexd@contoso.com"
}
}
)
}
)
}
New-MgGroupThread -GroupId $groupId -BodyParameter $params
Import-Module Microsoft.Graph.Groups
$params = @{
Topic = "New Conversation Thread Topic"
Posts = @(
@{
Body = @{
ContentType = "html"
Content = "this is body content"
}
NewParticipants = @(
@{
EmailAddress = @{
Name = "Alex Darrow"
Address = "alexd@contoso.com"
}
}
)
}
)
}
New-MgGroupThread -GroupId $groupId -BodyParameter $params
SDK をプロジェクトに追加し、authProvider インスタンスを作成する 方法の詳細については、SDK のドキュメントを参照してください 。
応答
応答の例を次に示します。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-type: application/json
{
"toRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
],
"topic": "topic-value",
"hasAttachments": true,
"lastDeliveredDateTime": "datetime-value",
"uniqueSenders": [
"uniqueSenders-value"
],
"ccRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
]
}