Пространство имен: microsoft.graph
Важно!
API версии /beta
в Microsoft Graph могут быть изменены. Использование этих API в производственных приложениях не поддерживается. Чтобы определить, доступен ли API в версии 1.0, используйте селектор версий.
Начните групповой чат, создав цепочку.
В группе создаются беседа, цепочка беседы и запись. Размещать в цепочке дальнейшие записи можно с помощью ответов на цепочки и записи.
Примечание. Вы также можете создать цепочку и существующей беседе.
Этот API доступен в следующих национальных облачных развертываниях.
Глобальная служба |
Правительство США L4 |
Правительство США L5 (DOD) |
Китай управляется 21Vianet |
✅ |
✅ |
✅ |
✅ |
Разрешения
Для вызова этого API требуется одно из следующих разрешений. Дополнительные сведения, включая сведения о том, как выбрать разрешения, см. в статье Разрешения.
Тип разрешения |
Разрешения (в порядке повышения привилегий) |
Делегированные (рабочая или учебная учетная запись) |
Group.ReadWrite.All |
Делегированные (личная учетная запись Майкрософт) |
Не поддерживается. |
Для приложений |
Не поддерживается. |
HTTP-запрос
POST /groups/{id}/threads
Текст запроса
Предоставьте в тексте запроса описание объекта conversationThread, содержащего объект post, в формате JSON.
Отклик
В случае успеха этот метод возвращает код отклика 201 Created
и объект conversationThread в тексте отклика.
Пример
Запрос
Ниже показан пример запроса.
POST https://graph.microsoft.com/beta/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": "[email protected]"
}
}]
}]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new ConversationThread
{
Topic = "New Conversation Thread Topic",
Posts = new List<Post>
{
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 = "[email protected]",
},
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Groups["{group-id}"].Threads.PostAsync(requestBody);
mgc-beta groups threads create --group-id {group-id} --body '{\
"topic": "New Conversation Thread Topic",\
"posts": [{\
"body": {\
"contentType": "html",\
"content": "this is body content"\
},\
"newParticipants": [{\
"emailAddress": {\
"name": "Alex Darrow",\
"address": "[email protected]"\
}\
}]\
}]\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewConversationThread()
topic := "New Conversation Thread Topic"
requestBody.SetTopic(&topic)
post := graphmodels.NewPost()
body := graphmodels.NewItemBody()
contentType := graphmodels.HTML_BODYTYPE
body.SetContentType(&contentType)
content := "this is body content"
body.SetContent(&content)
post.SetBody(body)
recipient := graphmodels.NewRecipient()
emailAddress := graphmodels.NewEmailAddress()
name := "Alex Darrow"
emailAddress.SetName(&name)
address := "[email protected]"
emailAddress.SetAddress(&address)
recipient.SetEmailAddress(emailAddress)
newParticipants := []graphmodels.Recipientable {
recipient,
}
post.SetNewParticipants(newParticipants)
posts := []graphmodels.Postable {
post,
}
requestBody.SetPosts(posts)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
threads, err := graphClient.Groups().ByGroupId("group-id").Threads().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
ConversationThread conversationThread = new ConversationThread();
conversationThread.setTopic("New Conversation Thread Topic");
LinkedList<Post> posts = new LinkedList<Post>();
Post post = new Post();
ItemBody body = new ItemBody();
body.setContentType(BodyType.Html);
body.setContent("this is body content");
post.setBody(body);
LinkedList<Recipient> newParticipants = new LinkedList<Recipient>();
Recipient recipient = new Recipient();
EmailAddress emailAddress = new EmailAddress();
emailAddress.setName("Alex Darrow");
emailAddress.setAddress("[email protected]");
recipient.setEmailAddress(emailAddress);
newParticipants.add(recipient);
post.setNewParticipants(newParticipants);
posts.add(post);
conversationThread.setPosts(posts);
ConversationThread result = graphClient.groups().byGroupId("{group-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: '[email protected]'
}
}]
}]
};
await client.api('/groups/{id}/threads')
.version('beta')
.post(conversationThread);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\ConversationThread;
use Microsoft\Graph\Beta\Generated\Models\Post;
use Microsoft\Graph\Beta\Generated\Models\ItemBody;
use Microsoft\Graph\Beta\Generated\Models\BodyType;
use Microsoft\Graph\Beta\Generated\Models\Recipient;
use Microsoft\Graph\Beta\Generated\Models\EmailAddress;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ConversationThread();
$requestBody->setTopic('New Conversation Thread Topic');
$postsPost1 = new Post();
$postsPost1Body = new ItemBody();
$postsPost1Body->setContentType(new BodyType('html'));
$postsPost1Body->setContent('this is body content');
$postsPost1->setBody($postsPost1Body);
$newParticipantsRecipient1 = new Recipient();
$newParticipantsRecipient1EmailAddress = new EmailAddress();
$newParticipantsRecipient1EmailAddress->setName('Alex Darrow');
$newParticipantsRecipient1EmailAddress->setAddress('[email protected]');
$newParticipantsRecipient1->setEmailAddress($newParticipantsRecipient1EmailAddress);
$newParticipantsArray []= $newParticipantsRecipient1;
$postsPost1->setNewParticipants($newParticipantsArray);
$postsArray []= $postsPost1;
$requestBody->setPosts($postsArray);
$result = $graphServiceClient->groups()->byGroupId('group-id')->threads()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Groups
$params = @{
topic = "New Conversation Thread Topic"
posts = @(
@{
body = @{
contentType = "html"
content = "this is body content"
}
newParticipants = @(
@{
emailAddress = @{
name = "Alex Darrow"
address = "[email protected]"
}
}
)
}
)
}
New-MgBetaGroupThread -GroupId $groupId -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.conversation_thread import ConversationThread
from msgraph_beta.generated.models.post import Post
from msgraph_beta.generated.models.item_body import ItemBody
from msgraph_beta.generated.models.body_type import BodyType
from msgraph_beta.generated.models.recipient import Recipient
from msgraph_beta.generated.models.email_address import EmailAddress
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ConversationThread(
topic = "New Conversation Thread Topic",
posts = [
Post(
body = ItemBody(
content_type = BodyType.Html,
content = "this is body content",
),
new_participants = [
Recipient(
email_address = EmailAddress(
name = "Alex Darrow",
address = "[email protected]",
),
),
],
),
],
)
result = await graph_client.groups.by_group_id('group-id').threads.post(request_body)
Отклик
Ниже показан пример отклика.
Примечание. Объект отклика, показанный здесь, может быть сокращен для удобочитаемости.
HTTP/1.1 201 Created
Content-type: application/json
{
"toRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
],
"topic": "topic-value",
"hasAttachments": true,
"lastDeliveredDateTime": "2016-10-19T10:37:00Z",
"uniqueSenders": [
"uniqueSenders-value"
],
"ccRecipients": [
{
"emailAddress": {
"name": "name-value",
"address": "address-value"
}
}
]
}