// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new TaskFileAttachment
{
OdataType = "#microsoft.graph.taskFileAttachment",
Name = "smile",
ContentBytes = Convert.FromBase64String("a0b1c76de9f7="),
ContentType = "image/gif",
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Me.Todo.Lists["{todoTaskList-id}"].Tasks["{todoTask-id}"].Attachments.PostAsync(requestBody);
// 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.NewAttachmentBase()
name := "smile"
requestBody.SetName(&name)
contentBytes := []byte("a0b1c76de9f7=")
requestBody.SetContentBytes(&contentBytes)
contentType := "image/gif"
requestBody.SetContentType(&contentType)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
attachments, err := graphClient.Me().Todo().Lists().ByTodoTaskListId("todoTaskList-id").Tasks().ByTodoTaskId("todoTask-id").Attachments().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TaskFileAttachment attachmentBase = new TaskFileAttachment();
attachmentBase.setOdataType("#microsoft.graph.taskFileAttachment");
attachmentBase.setName("smile");
byte[] contentBytes = Base64.getDecoder().decode("a0b1c76de9f7=");
attachmentBase.setContentBytes(contentBytes);
attachmentBase.setContentType("image/gif");
AttachmentBase result = graphClient.me().todo().lists().byTodoTaskListId("{todoTaskList-id}").tasks().byTodoTaskId("{todoTask-id}").attachments().post(attachmentBase);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.task_file_attachment import TaskFileAttachment
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TaskFileAttachment(
odata_type = "#microsoft.graph.taskFileAttachment",
name = "smile",
content_bytes = base64.urlsafe_b64decode("a0b1c76de9f7="),
content_type = "image/gif",
)
result = await graph_client.me.todo.lists.by_todo_task_list_id('todoTaskList-id').tasks.by_todo_task_id('todoTask-id').attachments.post(request_body)