Unable to upload attachment with create message

persistent_test 91 Reputation points
2022-04-15T10:23:40.343+00:00

POST API - https://graph.microsoft.com/v1.0/me/messages
https://learn.microsoft.com/en-us/graph/api/user-post-messages?view=graph-rest-1.0&tabs=http

Request Body-
{
"subject": "IPI-testing: concert",
"body": {
"contentType": "HTML",
"content": "The group represents Washington."
},
"toRecipients": [
{
"emailAddress": {
"address": "aktest@akendratest22.onmicrosoft.com"
}
}
],
"internetMessageHeaders": [
{
"name": "x-custom-header-group-name",
"value": "Washington"
},
{
"name": "x-custom-header-group-id",
"value": "WA001"
}
],
"attachments": [
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "attachment.txt",
"contentType": "text/plain",
"contentBytes": "SGVsbG8gV29ybGQh"
}
]
}

Result - working and default attachment is created.

Requirement - We want to upload our own attachments with bigger size we could not find upload attachment option

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,448 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Bhanu Kiran 3,526 Reputation points
    2022-04-15T12:47:14.583+00:00

    Hi @persistent_test

    This endpoint only supports to attach files that are smaller than 3 MB. To attach larger file in range of 3 MB to 150 MB, I would recommend you to use POST /me/messages/{id}/attachments/createUploadSession

    You can follow this resource article for detailed information: https://learn.microsoft.com/en-us/graph/api/attachment-createuploadsession?view=graph-rest-1.0&tabs=http

    If the answer is helpful, please click Accept Answer and kindly upvote it. If you have any further questions about this answer, please click Comment.

    0 comments No comments

  2. persistent_test 91 Reputation points
    2022-04-19T04:59:52.917+00:00

    Thank you for reply, I want attach file smaller than 3 mb with same API - https://graph.microsoft.com/v1.0/me/messages,
    But we could not find option for file attachment option with same API (other than default attachment option )

    could you please help here.

    0 comments No comments