Skip to content

Latest commit

 

History

History
149 lines (113 loc) · 6.02 KB

taskfileattachment-createuploadsession.md

File metadata and controls

149 lines (113 loc) · 6.02 KB
title description author ms.localizationpriority ms.subservice doc_type
taskFileAttachment: createUploadSession
Create an upload session to iteratively upload ranges of a file as an attachment to a Microsoft To Do task.
avijityadav
medium
outlook
apiPageType

taskFileAttachment: createUploadSession

Namespace: microsoft.graph

[!INCLUDE beta-disclaimer]

Create an upload session to iteratively upload ranges of a file as an attachment to a todoTask.

As part of the response, this action returns an upload URL that you can use in subsequent sequential PUT queries. The request headers for each PUT operation let you specify the exact range of bytes to be uploaded. This allows the transfer to be resumed, in case the network connection is dropped during the upload.

The following are the steps to attach a file to a Microsoft To Do task using an upload session:

  1. Create an upload session.
  2. Within that upload session, iteratively upload ranges of bytes (up to 4 MB each time) until all the bytes of the file have been uploaded, and the file is attached to the todoTask.
  3. Optional: Delete the upload session.

Note: Use this approach to attach a file of any supported size between 0 MB to 25 MB.

For an example that describes the end-to-end attachment process, see attach files to a To Do task.

[!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/createUploadSession
POST /users/{id}/todo/lists/{id}/tasks/{id}/attachments/createUploadSession

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 parameters.

The following table shows the parameter that can be used with this action.

Parameter Type Description
attachmentInfo attachmentInfo Represents attributes of the item to be uploaded and attached. At minimum, specify the attachment type (file), a name, and the size of the file.

Response

If successful, this action returns a 200 OK response code and a new uploadSession in the response body.

Examples

Request

The following example shows a request to create an upload session.

POST https://graph.microsoft.com/beta/me/todo/lists/AAMDiFkfh=/tasks/AAMkADliMm=/attachments/createUploadSession
Content-Type: application/json

{
  "attachmentInfo": {
    "attachmentType": "file",
    "name": "flower",
    "size": 3483322
  }
}

[!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]

[!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 200 OK
Content-Type: application/json

{
    "@odata.context": "https://graph.microsoft.com/beta/$metadata#microsoft.graph.uploadSession",
    "uploadUrl": "https://graph.microsoft.com/beta/users/6f9a2a92-8527-4d64-837e-b5312852f36d/todo/lists/AAMDiFkfh=/tasks/AAMkADliMm=/attachmentSessions/AAMkADliMm=",
    "expirationDateTime": "2022-06-09T10:45:27.4324526Z",
    "nextExpectedRanges": [
        "0-"
    ]
}