Skip to content

Latest commit

 

History

History
136 lines (106 loc) · 5 KB

File metadata and controls

136 lines (106 loc) · 5 KB
title Create taskFileAttachment
description Add a new taskFileAttachment object to a todoTask.
author avijityadav
ms.localizationpriority medium
ms.subservice outlook
doc_type apiPageType
ms.date 04/04/2024

Create taskFileAttachment

Namespace: microsoft.graph

Add a new taskFileAttachment object to a todoTask.

This operation limits the size of the attachment you can add to under 3 MB. If the size of the file attachments is more than 3 MB, create an upload session to upload the attachments.

[!INCLUDE national-cloud-support]

Permissions

Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.

[!INCLUDE permissions-table]

HTTP request

POST /me/todo/lists/{id}/tasks/{id}/attachments
POST /users/{id}/todo/lists/{id}/tasks/{id}/attachments

Request headers

Name Description
Authorization Bearer {token}. Required. Learn more about authentication and authorization.
Content-Type application/json. Required.

Request body

In the request body, supply a JSON representation of the taskFileAttachment object.

When you create a file attachment, include "@odata.type": "#microsoft.graph.taskFileAttachment" and the required properties.

Property Type Description
contentBytes Binary The base64-encoded contents of the file. Required.
contentType String The content type of the attachment.
name String The name of the text displayed under the icon that represents the embedded attachment. This does not need to be the actual file name. Required.
size Int32 The size in bytes of the attachment.

Response

If successful, this method returns a 201 Created response code and a taskFileAttachment object in the response body.

Examples

Request

The following example shows a request.

POST https://graph.microsoft.com/v1.0/me/todo/lists/AAMkpsDRVK=/tasks/AAKdfjhgsjhgJ=/attachments
Content-Type: application/json

{
  "@odata.type": "#microsoft.graph.taskFileAttachment",
  "name": "smile",
  "contentBytes": "a0b1c76de9f7=",
  "contentType": "image/gif"
}

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]

[!INCLUDE sample-code] [!INCLUDE sdk-documentation]


Response

The following example shows the response.

Note: The response object shown here might be shortened for readability.

HTTP/1.1 201 Created
Content-Type: application/json

{
  "@odata.type": "#microsoft.graph.taskFileAttachment",
  "id": "AAMkADNkN2R",
  "lastModifiedDateTime": "2017-01-26T08:48:28Z",
  "name": "smile",
  "contentType": "image/gif",
  "size": 1008
}