命名空间:microsoft.graph
从用户日历事件、邮件或组帖子中删除附件。
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
✅ |
✅ |
✅ |
权限
根据附件附加到的资源 (事件、 消息、 outlookTask 或 post) ,以及请求的权限类型 (委托或应用程序) ,下表中指定的权限是调用此 API 所需的最低特权。 若要了解其他信息, 在 特权权限之前要特别小心,在"权限" 中搜索。
支持的资源 |
委派(工作或学校帐户) |
委派(个人 Microsoft 帐户) |
应用程序 |
事件 |
Calendars.ReadWrite |
Calendars.ReadWrite |
Calendars.ReadWrite |
邮件 |
Mail.ReadWrite |
Mail.ReadWrite |
Mail.ReadWrite |
帖子 |
Group.ReadWrite.All |
不支持 |
不支持 |
HTTP 请求
用户的默认日历中的事件附件。
DELETE /me/events/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/events/{id}/attachments/{id}
DELETE /me/calendar/events/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/calendar/events/{id}/attachments/{id}
指定日历中属于用户的事件的附件。
DELETE /me/calendars/{id}/events/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/calendars/{id}/events/{id}/attachments/{id}
属于用户默认 calendarGroup 的日历中事件的附件。
DELETE /me/calendars/{id}/events/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/calendars/{id}/events/{id}/attachments/{id}
属于用户的 calendarGroup 的日历中事件的附件。
DELETE /me/calendarGroups/{id}/calendars/{id}/events/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/calendarGroups/{id}/calendars/{id}/events/{id}/attachments/{id}
用户邮箱中的 邮件 附件。
DELETE /me/messages/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/messages/{id}/attachments/{id}
用户邮箱的顶级 mailFolder 中包含的 邮件 附件。
DELETE /me/mailFolders/{id}/messages/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/mailFolders/{id}/messages/{id}/attachments/{id}
用户邮箱的 mailFolder 的子文件夹中包含的 邮件 附件。 以下示例演示了一个嵌套级别,但消息可以位于子级等子级中。
DELETE /me/mailFolders/{id}/childFolders/{id}/.../messages/{id}/attachments/{id}
DELETE /users/{id | userPrincipalName}/mailFolders/{id}/childFolders/{id}/messages/{id}/attachments/{id}
属于组对话的线程中帖子的附件。
DELETE /groups/{id}/threads/{id}/posts/{id}/attachments/{id}
DELETE /groups/{id}/conversations/{id}/threads/{id}/posts/{id}/attachments/{id}
名称 |
类型 |
说明 |
Authorization |
string |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法返回 204 No Content
响应代码。 它不会在响应正文中返回任何内容。
示例
请求
以下示例显示了删除事件附件的请求。
DELETE https://graph.microsoft.com/v1.0/me/events/{id}/attachments/{id}
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Events["{event-id}"].Attachments["{attachment-id}"].DeleteAsync();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
mgc users events attachments delete --user-id {user-id} --event-id {event-id} --attachment-id {attachment-id}
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
//other-imports
)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Events().ByEventId("event-id").Attachments().ByAttachmentId("attachment-id").Delete(context.Background(), nil)
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.me().events().byEventId("{event-id}").attachments().byAttachmentId("{attachment-id}").delete();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/me/events/{id}/attachments/{id}')
.delete();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
<?php
use Microsoft\Graph\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->me()->events()->byEventId('event-id')->attachments()->byAttachmentId('attachment-id')->delete()->wait();
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
Import-Module Microsoft.Graph.Calendar
# A UPN can also be used as -UserId.
Remove-MgUserEventAttachment -UserId $userId -EventId $eventId -AttachmentId $attachmentId
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.me.events.by_event_id('event-id').attachments.by_attachment_id('attachment-id').delete()
有关如何将 SDK 添加到项目并创建 authProvider 实例的详细信息,请参阅 SDK 文档。
响应
以下示例显示了相应的响应。
HTTP/1.1 204 No Content