Nota
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare ad accedere o modificare le directory.
L'accesso a questa pagina richiede l'autorizzazione. È possibile provare a modificare le directory.
Namespace: microsoft.graph
Important
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Create a fileAttachment object, which adds an inline image attachment to a note. Only image file types (image/png, image/jpeg, image/gif, or image/bmp) are supported, with a maximum size of 3 MB per attachment. Use the contentId property to reference the attachment in the HTML body of a note by using <img src="cid:{contentId}" />.
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.
| Permission type | Least privileged permissions | Higher privileged permissions |
|---|---|---|
| Delegated (work or school account) | ShortNotes.ReadWrite | Not available. |
| Delegated (personal Microsoft account) | ShortNotes.ReadWrite | Not available. |
| Application | ShortNotes.ReadWrite.All | Not available. |
HTTP request
POST /me/notes/{note-id}/attachments
POST /users/{id | userPrincipalName}/notes/{note-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 fileAttachment object.
You can specify the following properties when you create an attachment.
| Property | Type | Description |
|---|---|---|
| @odata.type | String | The OData type of the attachment resource. Required. Set to #microsoft.graph.fileAttachment. |
| name | String | The file name of the attachment. Required. |
| contentType | String | The MIME type of the attachment. Must be an image type: image/png, image/jpeg, image/gif, or image/bmp. Required. |
| contentBytes | String | The base64-encoded contents of the file. Required. |
| contentId | String | The ID used for referencing the attachment in the HTML body via cid:. Required. |
| isInline | Boolean | Indicates whether the attachment is an inline attachment. Must be set to true for note attachments. Required. |
Response
If successful, this method returns a 201 Created response code and an attachment object in the response body.
Examples
Request
The following example shows a request.
POST https://graph.microsoft.com/beta/me/notes/AAMkAGI2THVSAAA=/attachments
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.fileAttachment",
"name": "screenshot.png",
"contentType": "image/png",
"contentBytes": "iVBORw0KGgoAAAANSUhEUgAAAAUA...",
"contentId": "screenshot-001",
"isInline": true
}
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.fileAttachment",
"id": "AAMkAGI2attach2",
"name": "screenshot.png",
"contentType": "image/png",
"size": 12456,
"isInline": true,
"contentId": "screenshot-001",
"lastModifiedDateTime": "2024-01-29T11:30:00Z"
}