更新开放扩展Update open extension

命名空间:microsoft.graphNamespace: microsoft.graph

通过请求正文中的属性更新开放扩展(openTypeExtension 对象):Update an open extension (openTypeExtension object) with the properties in the request body:

  • 如果请求正文中的属性与现有属性在扩展中的名称相匹配,则更新扩展中的数据。If a property in the request body matches the name of an existing property in the extension, the data in the extension is updated.
  • 否则,属性及其数据将添加到扩展中。Otherwise that property and its data are added to the extension.

扩展插件中的数据可以是基元类型,也可以是基元类型数组。The data in an extension can be primitive types, or arrays of primitive types.

权限Permissions

根据在其中创建扩展的资源以及请求的权限类型 (委派或应用程序) ,下表中指定的权限是调用此 API 所需的最低特权。Depending on the resource that the extension was created in and the permission type (delegated or application) requested, the permission specified in the following table is the least privileged required to call this API. 若要了解详细信息,包括如何选择权限的信息,请参阅权限To learn more, including how to choose permissions, see Permissions.

支持的资源Supported resource 委派(工作或学校帐户)Delegated (work or school account) 委派(个人 Microsoft 帐户)Delegated (personal Microsoft account) 应用程序Application
设备device Directory.AccessAsUser.AllDirectory.AccessAsUser.All 不支持Not supported Device.ReadWrite.AllDevice.ReadWrite.All
事件event Calendars.ReadWriteCalendars.ReadWrite Calendars.ReadWriteCalendars.ReadWrite Calendars.ReadWriteCalendars.ReadWrite
group Group.ReadWrite.AllGroup.ReadWrite.All 不支持Not supported Group.ReadWrite.AllGroup.ReadWrite.All
组事件group event Group.ReadWrite.AllGroup.ReadWrite.All 不支持Not supported 不支持Not supported
组帖子group post Group.ReadWrite.AllGroup.ReadWrite.All 不支持Not supported Group.ReadWrite.AllGroup.ReadWrite.All
邮件message Mail.ReadWriteMail.ReadWrite Mail.ReadWriteMail.ReadWrite Mail.ReadWriteMail.ReadWrite
组织organization Organization.ReadWrite.AllOrganization.ReadWrite.All 不支持Not supported Organization.ReadWrite.AllOrganization.ReadWrite.All
个人联系人personal contact Contacts.ReadWriteContacts.ReadWrite Contacts.ReadWriteContacts.ReadWrite Contacts.ReadWriteContacts.ReadWrite
用户user User.ReadWriteUser.ReadWrite User.ReadWriteUser.ReadWrite User.ReadWrite.AllUser.ReadWrite.All
tasktask Tasks.ReadWriteTasks.ReadWrite Tasks.ReadWriteTasks.ReadWrite 全部写读。Tasks.ReadWrite.All
tasklisttasklist Tasks.ReadWriteTasks.ReadWrite Tasks.ReadWriteTasks.ReadWrite 全部写读。Tasks.ReadWrite.All

HTTP 请求HTTP request

在请求中,标识资源实例,使用资源实例的 extensions 导航属性标识扩展插件,然后对此扩展插件实例执行 PATCHIn the request, identify the resource instance, use the extensions navigation property of that instance to identify the extension, and do a PATCH on that extension instance.

PATCH /devices/{Id}/extensions/{extensionId}
PATCH /users/{id|userPrincipalName}/events/{id}/extensions/{extensionId}
PATCH /groups/{id}/extensions/{extensionId}
PATCH /groups/{id}/events/{id}/extensions/{extensionId}
PATCH /groups/{id}/threads/{id}/posts/{id}/extensions/{extensionId}
PATCH /users/{id|userPrincipalName}/messages/{id}/extensions/{extensionId}
PATCH /organization/{Id}/extensions/{extensionId}
PATCH /users/{id|userPrincipalName}/contacts/{id}/extensions/{extensionId}
PATCH /users/{id|userPrincipalName}/extensions/{extensionId}
PATCH /users/me/todo/lists/{todoTaskListId}/tasks/{taskId}/extensions/{extensionId}
PATCH /users/me/todo/lists/{todoTaskListId}/extensions/{extensionId}

注意: 以上语法显示一些标识资源实例的常见方法,以便在其中更新一个扩展。可以用来标识这些资源实例的所有其他语法均支持以类似的方式在其中更新开放扩展。Note: The above syntax shows some common ways to identify a resource instance, in order to update an extension in it. All other syntax that allows you to identify these resource instances supports updating open extensions in them in a similar way.

若要了解如何在请求正文中添加任意自定义数据来进行更改或添加到扩展插件,请参阅请求正文部分。See the Request body section about including in the request body any custom data to change or add to that extension.

路径参数Path parameters

参数Parameter 类型Type 说明Description
idid stringstring 相应集合的实例的唯一标识符。必需。A unique identifier for an instance of the corresponding collection. Required.
extensionIdextensionId stringstring 这可以是一个扩展名称(即扩展的唯一文本标识符)或完全限定的名称(连接扩展类型和唯一文本标识符)。创建扩展时,在 id 属性中返回完全限定的名称。必需。This can be an extension name which is a unique text identifier for an extension, or a fully qualified name which concatenates the extension type and unique text identifier. The fully qualified name is returned in the id property when you create the extension. Required.

请求标头Request headers

名称Name Value
AuthorizationAuthorization Bearer {token}。必需。Bearer {token}. Required.
Content-TypeContent-Type application/jsonapplication/json

请求正文Request body

提供 openTypeExtension 对象的 JSON 正文(具有以下所需的名称-值对)以及要更改或添加到该扩展中的任意定义数据。JSON 负载中的数据可以是基元或基元数组类型。Provide a JSON body of an openTypeExtension object, with the following required name-value pairs, and any custom data to change or add to that extension. The data in the JSON payload can be primitive types, or arrays of primitive types.

名称Name Value
@odata.type@odata.type microsoft.graph.openTypeExtensionmicrosoft.graph.openTypeExtension
extensionNameextensionName %unique_string%%unique_string%

响应Response

如果成功,此方法返回 200 OK 响应代码和更新的 openTypeExtension 对象。If successful, this method returns a 200 OK response code and the updated openTypeExtension object.

示例Example

请求 1Request 1

第一个示例展示如何在邮件中更新扩展。该扩展最初由以下 JSON 负载表示:The first example shows how to update an extension in a message. The extension is initially represented by the following JSON payload:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/messages('AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===')/extensions/$entity",
    "@odata.type": "#microsoft.graph.openTypeExtension",
    "@odata.id": "https://graph.microsoft.com/v1.0/users('ddfc984d-b826-40d7-b48b-57002df85e00@1717f226-49d1-4d0c-9d74-709fad6677b4')/messages('AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===')/extensions
('Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Referral')",
    "extensionName": "Com.Contoso.Referral",
    "id": "Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Referral",
    "companyName": "Wingtip Toys",
    "dealValue": 500050,
    "expirationDate": "2015-12-03T10:00:00Z"
}

可以按其名称引用该扩展,You can reference the extension by its name:

PATCH https://graph.microsoft.com/v1.0/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions/Com.Contoso.Referral

或者,也可以通过其完全限定的名称引用扩展:Or you can reference the extension by its fully qualified name:

PATCH https://graph.microsoft.com/v1.0/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions/Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Referral

可以通过以下方法,使用示例请求和以下请求正文更新以上扩展:You can use either example request and the following request body to update the above extension by:

  • companyNameWingtip Toys 更改为 Wingtip Toys (USA)Changing companyName from Wingtip Toys to Wingtip Toys (USA)
  • dealValue500050 更改为 500100Changing dealValue from 500050 to 500100
  • 将新数据添加为自定义属性 updatedAdding new data as the custom property updated
{
    "@odata.type": "microsoft.graph.openTypeExtension",
    "extensionName": "Com.Contoso.Referral",
    "companyName": "Wingtip Toys (USA)",
    "dealValue": "500100",
    "expirationDate": "2015-12-03T10:00:00.000Z",
    "updated": "2015-10-29T11:00:00.000Z"
} 

响应 1Response 1

无论用于引用扩展的方式如何,该响应都相同。Here is the response which is the same regardless of the way used to reference the extension.

HTTP/1.1 200 OK
Content-type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Me/messages('AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===')/extensions/$entity",
    "@odata.type": "#microsoft.graph.openTypeExtension",
    "@odata.id": "https://graph.microsoft.com/v1.0/users('ddfc984d-b826-40d7-b48b-57002df85e00@1717f226-49d1-4d0c-9d74-709fad6677b4')/messages('AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===')/extensions
('Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Referral')",
    "id": "Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Referral",
    "extensionName": "Com.Contoso.Referral",
    "companyName": "Wingtip Toys (USA)",
    "dealValue": 500100,
    "expirationDate": "2015-12-03T10:00:00Z",
    "updated": "2015-10-29T11:00:00.000Z"
}

请求 2Request 2

第二个示例展示如何在组帖子中更新扩展。该扩展最初由以下 JSON 负载表示,其中的 expirationDate 的值为 2015-07-03T13:04:00ZThe second example shows how to update an extension in a group post. The extension is initially represented by the following JSON payload, with an expirationDate value of 2015-07-03T13:04:00Z:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups('37df2ff0-0de0-4c33-8aee-75289364aef6')/threads('AAQkADJizZJpEWwqDHsEpV_KA%3D%3D')/posts('AAMkADJiUg96QZUkA-ICwMubAADDEd7UAAA%3D')/extensions/$entity",
    "@odata.type": "#microsoft.graph.openTypeExtension",
    "id": "Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Estimate",
    "extensionName": "Com.Contoso.Estimate",
    "companyName": "Contoso",
    "expirationDate": "2015-07-03T13:04:00Z",
    "DealValue": 1010100,
    "Strings@odata.type": "#Collection(String)",
    "topPicks": [
        "Employees only",
        "Add spouse or guest",
        "Add family"
    ]
}

以下是要将 expirationDate 更改为 2016-07-30T11:00:00Z 的请求和请求正文:The following is the request and request body to change the expirationDate to 2016-07-30T11:00:00Z:

PATCH https://graph.microsoft.com/v1.0/groups/37df2ff0-0de0-4c33-8aee-75289364aef6/threads/AAQkADJizZJpEWwqDHsEpV_KA==/posts/AAMkADJiUg96QZUkA-ICwMubAADDEd7UAAA=/extensions/Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Estimate
Content-type: application/json

{
   "@odata.type": "Microsoft.OutlookServices.OpenTypeExtension",
   "extensionName": "Com.Contoso.Estimate",
   "companyName": "Contoso",
   "expirationDate": "2016-07-30T11:00:00.000Z",
   "DealValue": 1010100,
   "topPicks": [
       "Employees only",
       "Add spouse or guest",
       "Add family"
    ]
}

响应 2Response 2

下面是第二个示例的响应,显示了扩展中更新的 expirationDateHere is the response of the second example which shows the updated expirationDate in the extension.

HTTP/1.1 200 OK
Content-Type: application/json

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups('37df2ff0-0de0-4c33-8aee-75289364aef6')/threads('AAQkADJizZJpEWwqDHsEpV_KA%3D%3D')/posts('AAMkADJiUg96QZUkA-ICwMubAADDEd7UAAA%3D')/extensions/$entity",
    "@odata.type": "#microsoft.graph.openTypeExtension",
    "id": "Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Estimate",
    "extensionName": "Com.Contoso.Estimate",
    "companyName": "Contoso",
    "expirationDate": "2016-07-30T11:00:00Z",
    "DealValue": 1010100,
    "Strings@odata.type": "#Collection(String)",
    "topPicks": [
        "Employees only",
        "Add spouse or guest",
        "Add family"
    ]
}