All diese Typen von Anlagenressourcen werden von der Ressource attachment abgeleitet.
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)
POST https://graph.microsoft.com/v1.0/groups/1848753d-185d-4c08-a4e4-6ee40521d115/threads/AAQkADJUdfolA==/reply
Content-type: application/json
{
"post": {
"body": {
"contentType": "text",
"content": "Which quarter does that file cover? See my attachment."
},
"attachments": [{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "Another file as attachment",
"contentBytes": "VGhpcyBpcyBhIGZpbGUgdG8gYmUgYXR0YWNoZWQu"
} ]
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var post = new Post
{
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "Which quarter does that file cover? See my attachment."
},
Attachments = new PostAttachmentsCollectionPage()
{
new FileAttachment
{
Name = "Another file as attachment",
ContentBytes = Encoding.ASCII.GetBytes("VGhpcyBpcyBhIGZpbGUgdG8gYmUgYXR0YWNoZWQu")
}
}
};
await graphClient.Groups["{group-id}"].Threads["{conversationThread-id}"]
.Reply(post)
.Request()
.PostAsync();
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewPostRequestBody()
post := msgraphsdk.NewPost()
requestBody.SetPost(post)
body := msgraphsdk.NewItemBody()
post.SetBody(body)
contentType := "text"
body.SetContentType(&contentType)
content := "Which quarter does that file cover? See my attachment."
body.SetContent(&content)
post.SetAttachments( []Attachment {
msgraphsdk.NewAttachment(),
name := "Another file as attachment"
SetName(&name)
SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.fileAttachment",
"contentBytes": "VGhpcyBpcyBhIGZpbGUgdG8gYmUgYXR0YWNoZWQu",
}
}
groupId := "group-id"
conversationThreadId := "conversationThread-id"
graphClient.GroupsById(&groupId).ThreadsById(&conversationThreadId).Reply(group-id, conversationThread-id).Post(requestBody)
Hier ist ein Beispiel für eine Anforderung, die beim Erstellen eines Beitrags ein Ereignis als Anlage enthält.
POST https://graph.microsoft.com/v1.0/groups/1848753d-185d-4c08-a4e4-6ee40521d115/threads/AAQkADJUdfolA==/reply
Content-type: application/json
{
"post": {
"body": {
"contentType": "text",
"content": "I attached an event."
},
"attachments": [{
"@odata.type": "#microsoft.graph.itemAttachment",
"name": "Holiday event",
"item": {
"@odata.type": "microsoft.graph.event",
"subject": "Discuss gifts for children",
"body": {
"contentType": "HTML",
"content": "Let's look for funding!"
},
"start": {
"dateTime": "2019-12-02T18:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2019-12-02T19:00:00",
"timeZone": "Pacific Standard Time"
}
}
} ]
}
}
Antwort
Nachfolgend sehen Sie ein Beispiel der Antwort.
HTTP/1.1 202 Accepted
Beispiel 3: Einschließen einer Referenzanlage
Anforderung
Hier ist ein Beispiel für eine Anforderung, die beim Erstellen eines Beitrags eine Referenzanlage enthält.
Die Anlage verweist auf einen Ordner auf OneDrive.
POST https://graph.microsoft.com/v1.0/groups/1848753d-185d-4c08-a4e4-6ee40521d115/threads/AAQkADJUdfolA==/reply
Content-type: application/json
{
"post": {
"body": {
"contentType": "text",
"content": "I attached a reference to a file on OneDrive."
},
"attachments": [{
"@odata.type": "#microsoft.graph.referenceAttachment",
"name": "Personal pictures",
"sourceUrl": "https://contoso.com/personal/mario_contoso_net/Documents/Pics",
"providerType": "oneDriveConsumer",
"permission": "Edit",
"isFolder": "True"
} ]
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var post = new Post
{
Body = new ItemBody
{
ContentType = BodyType.Text,
Content = "I attached an event."
},
Attachments = new PostAttachmentsCollectionPage()
{
new ItemAttachment
{
Name = "Holiday event",
Item = new Event
{
Subject = "Discuss gifts for children",
Body = new ItemBody
{
ContentType = BodyType.Html,
Content = "Let's look for funding!"
},
Start = new DateTimeTimeZone
{
DateTime = "2019-12-02T18:00:00",
TimeZone = "Pacific Standard Time"
},
End = new DateTimeTimeZone
{
DateTime = "2019-12-02T19:00:00",
TimeZone = "Pacific Standard Time"
}
}
}
}
};
await graphClient.Groups["{group-id}"].Threads["{conversationThread-id}"]
.Reply(post)
.Request()
.PostAsync();