Unterhaltungsthread erstellen
Artikel
07/18/2022
6 Minuten Lesedauer
3 Mitwirkende
In diesem Artikel
Namespace: microsoft.graph
Beginnt eine neue Gruppenunterhaltung, indem zunächst ein Thread erstellt wird.
Eine neue Unterhaltung, Unterhaltungsthreads und Beiträge werden in der Gruppe erstellt. Verwenden Sie Auf Thread antworten oder Auf Beitrag antworten , um weitere Beiträge zu diesem Thread hinzuzufügen.
Hinweis: Sie können auch eine neuen Threads in einer bestehenden Unterhaltung beginnen .
Berechtigungen
Eine der nachfolgenden Berechtigungen ist erforderlich, um diese API aufrufen zu können. Weitere Informationen, unter anderem zur Auswahl von Berechtigungen, finden Sie im Artikel zum Thema Berechtigungen .
Berechtigungstyp
Berechtigungen (von der Berechtigung mit den wenigsten Rechten zu der mit den meisten Rechten)
Delegiert (Geschäfts-, Schul- oder Unikonto)
Group.ReadWrite.All
Delegiert (persönliches Microsoft-Konto)
Nicht unterstützt
Anwendung
Nicht unterstützt
HTTP-Anforderung
POST /groups/{id}/threads
Kopfzeile
Wert
Authorization
Bearer {token}. Erforderlich.
Content-Type
application/json
Anforderungstext
Geben Sie im Anforderungstext eine JSON-Darstellung des conversationThread -Objekts an, das einen Beitrag enthält.
Antwort
Wenn die Methode erfolgreich verläuft, werden der Antwortcode 201 Created und ein conversationThread -Objekt im Antworttext zurückgegeben.
Beispiel
Anforderung
Nachfolgend sehen Sie ein Beispiel der Anforderung.
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);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
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);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
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];
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
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);
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
//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)
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
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
Ausführliche Informationen zum Hinzufügen des SDK zu Ihrem Projekt und zum Erstellen einer authProvider-Instanz finden Sie in der SDK-Dokumentation .
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
Hinweis: Das hier gezeigte Antwortobjekt kann zur besseren Lesbarkeit gekürzt werden.
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"
}
}
]
}