创建多值扩展属性

命名空间:microsoft.graph

在新建或现有的资源实例中创建一个或多个多值扩展属性。

支持以下用户资源:

支持以下组资源:

有关何时使用开放扩展或扩展属性,以及如何指定扩展属性的详细信息,请参阅扩展属性概述

此 API 可用于以下国家级云部署

全局服务 美国政府 L4 美国政府 L5 (DOD) 由世纪互联运营的中国

权限

根据要创建扩展属性的资源以及请求 (委托或应用程序) 的权限类型,下表中指定的权限是调用此 API 所需的最低权限。 若要了解详细信息,包括如何选择权限的信息,请参阅权限

支持的资源 委派(工作或学校帐户) 委派(个人 Microsoft 帐户) 应用程序
calendar Calendars.ReadWrite Calendars.ReadWrite Calendars.ReadWrite
联系人 Contacts.ReadWrite Contacts.ReadWrite Contacts.ReadWrite
contactFolder Contacts.ReadWrite Contacts.ReadWrite Contacts.ReadWrite
事件 Calendars.ReadWrite Calendars.ReadWrite Calendars.ReadWrite
日历 Group.ReadWrite.All 不支持 不支持
事件 Group.ReadWrite.All 不支持 不支持
帖子 Group.ReadWrite.All 不支持 不支持
mailFolder Mail.ReadWrite Mail.ReadWrite Mail.ReadWrite
邮件 Mail.ReadWrite Mail.ReadWrite Mail.ReadWrite

HTTP 请求

可以在新建或现有的资源实例中创建扩展属性。

若要在新的资源实例中创建一个或多个扩展属性,请使用与创建实例相同的 REST 请求,并包括新资源实例的属性和请求正文中的扩展属性。 某些资源支持以多种方式创建。 有关创建这些资源实例的详细信息,请参阅创建 邮件mailFolder事件日历联系人contactFolder组事件组帖子 的相应主题。

以下是请求的语法。

POST /me/messages
POST /users/{id|userPrincipalName}/messages
POST /me/mailFolders/{id}/messages

POST /me/mailFolders
POST /users/{id|userPrincipalName}/mailFolders

POST /me/events
POST /users/{id|userPrincipalName}/events

POST /me/calendars
POST /users/{id|userPrincipalName}/calendars

POST /me/contacts
POST /users/{id|userPrincipalName}/contacts

POST /me/contactFolders
POST /users/{id|userPrincipalName}/contactFolders

POST /groups/{id}/events

POST /groups/{id}/threads/{id}/posts/{id}/reply
POST /groups/{id}/conversations/{id}/threads/{id}/posts/{id}/reply
POST /groups/{id}/threads/{id}/reply
POST /groups/{id}/conversations/{id}/threads/{id}/reply
POST /groups/{id}/threads
POST /groups/{id}/conversations

若要在现有资源实例中创建一个或多个扩展属性,请在请求中指定实例,并在请求正文中包括扩展属性。

注意 无法在现有组帖子中创建扩展属性。

PATCH /me/messages/{id}
PATCH /users/{id|userPrincipalName}/messages/{id}
PATCH /me/mailFolders/{id}/messages/{id}

PATCH /me/mailFolders/{id}
PATCH /users/{id|userPrincipalName}/mailFolders/{id}

PATCH /me/events/{id}
PATCH /users/{id|userPrincipalName}/events/{id}

PATCH /me/calendars/{id}
PATCH /users/{id|userPrincipalName}/calendars/{id}

PATCH /me/contacts/{id}
PATCH /users/{id|userPrincipalName}/contacts/{id}

PATCH /me/contactFolders/{id}
PATCH /users/{id|userPrincipalName}/contactFolders/{id}

PATCH /groups/{id}/events/{id}

请求标头

名称
Authorization 持有者 {token}。 必填。 详细了解 身份验证和授权
Content-Type application/json

请求正文

提供每个 multiValueLegacyExtendedProperty 对象在资源实例的 multiValueExtendedProperties 集合属性中的 JSON 正文。

属性 类型 说明
multiValueExtendedProperties multiValueLegacyExtendedProperty 集合 一个或多个多值扩展属性的数组。
id String 对于 multiValueExtendedProperties 集合中的每个属性,请指定此参数以标识属性。 它必须遵照其中一种支持的格式。 有关详细信息,请参阅 Outlook 扩展属性概述。 必需。
string 对于 multiValueExtendedProperties 集合中的每个属性,请指定属性值。 必填。

在新资源实例中创建扩展属性时,除了新的 multiValueExtendedProperties 集合外,还提供该资源实例的 JSON 表示形式以及 (,即消息mailFolderevent 等 ) 。

响应

响应代码

在新建资源实例中成功创建扩展属性的操作返回 201 Created(在新的组帖子中除外),根据所用的方法,该操作可以返回 200 OK202 Accepted

在现有的资源实例中,成功的创建操作返回 200 OK

响应正文

在支持的资源(而不是 组帖子)中创建扩展属性时,该响应只包括新建或现有的实例,但不包括新的扩展属性。 若要查看新创建的扩展属性,请 获取通过扩展属性展开的实例

新建的组帖子中创建扩展属性时,响应仅包括响应代码,但不包括新帖子或扩展属性。 无法在现有组帖子中创建扩展属性。

示例

示例 1:为事件创建多值扩展属性

请求

第一个示例在同一个 POST 操作的全新事件中创建一个多值扩展属性。 除了通常为新事件包含的属性外,请求正文还包括包含一个扩展属性的 multiValueExtendedProperties 集合。 请求正文包括该多值扩展属性的如下参数:

  • id,将此属性指定为包含指定 GUID 和 Recreation 名称的字符串数组。
  • value,将 Recreation 指定为包含 3 个字符串值(["Food", "Hiking", "Swimming"])的数组。
POST https://graph.microsoft.com/v1.0/me/events
Content-Type: application/json

{
  "subject": "Family reunion",
  "body": {
    "contentType": "HTML",
    "content": "Let's get together this Thanksgiving!"
  },
  "start": {
      "dateTime": "2015-11-26T09:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "end": {
      "dateTime": "2015-11-29T21:00:00",
      "timeZone": "Pacific Standard Time"
  },
  "attendees": [
    {
      "emailAddress": {
        "address": "Terrie@contoso.com",
        "name": "Terrie Barrera"
      },
      "type": "Required"
    },
    {
      "emailAddress": {
        "address": "Lauren@contoso.com",
        "name": "Lauren Solis"
      },
      "type": "Required"
    }
  ],
  "multiValueExtendedProperties": [
     {
           "id":"StringArray {66f5a359-4659-4830-9070-00050ec6ac6e} Name Recreation",
           "value": ["Food", "Hiking", "Swimming"]
     }
  ]
}

响应

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

{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4d29052a-70e8-4251-a7de-542b522cdf25')/events/$entity",
  "@odata.etag": "W/\"F458GvdYA0ijqgp2gyJwzAAAOCEJmw==\"",
  "id": "AAMkADI0NzVmYjQ0LWQyZTItNDIxYS1iMWE2LTIyZGJiOGM0N2YzMQBGAAAAAABaZwRaNsIxTp0lpjY1il_IBwAXjnwa91gDSKOqCnaDInDMAAAAAAENAAAXjnwa91gDSKOqCnaDInDMAAA4KToJAAA=",
  "createdDateTime": "2023-06-23T00:52:52.5418Z",
  "lastModifiedDateTime": "2023-06-23T00:52:53.570523Z",
  "changeKey": "F458GvdYA0ijqgp2gyJwzAAAOCEJmw==",
  "categories": [],
  "transactionId": null,
  "originalStartTimeZone": "Pacific Standard Time",
  "originalEndTimeZone": "Pacific Standard Time",
  "iCalUId": "040000008200E00074C5B7101A82E008000000001076340A6DA5D9010000000000000000100000003EE8BF77931D7D40B835A528EFD465E8",
  "reminderMinutesBeforeStart": 15,
  "isReminderOn": true,
  "hasAttachments": false,
  "subject": "Family reunion",
  "bodyPreview": "Let's get together this Thanksgiving!",
  "importance": "normal",
  "sensitivity": "normal",
  "isAllDay": false,
  "isCancelled": false,
  "isOrganizer": true,
  "responseRequested": true,
  "seriesMasterId": null,
  "showAs": "busy",
  "type": "singleInstance",
  "webLink": "https://outlook.office365.com/owa/?itemid=AAMkADI0NzVmYjQ0LWQyZTItNDIxYS1iMWE2LTIyZGJiOGM0N2YzMQBGAAAAAABaZwRaNsIxTp0lpjY1il%2BIBwAXjnwa91gDSKOqCnaDInDMAAAAAAENAAAXjnwa91gDSKOqCnaDInDMAAA4KToJAAA%3D&exvsurl=1&path=/calendar/item",
  "onlineMeetingUrl": null,
  "isOnlineMeeting": false,
  "onlineMeetingProvider": "unknown",
  "allowNewTimeProposals": true,
  "occurrenceId": null,
  "isDraft": false,
  "hideAttendees": false,
  "responseStatus": {
      "response": "organizer",
      "time": "0001-01-01T00:00:00Z"
  },
  "body": {
      "contentType": "html",
      "content": "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>Let's get together this Thanksgiving!</body></html>"
  },
  "start": {
      "dateTime": "2015-11-26T09:00:00.0000000",
      "timeZone": "Pacific Standard Time"
  },
  "end": {
      "dateTime": "2015-11-29T21:00:00.0000000",
      "timeZone": "Pacific Standard Time"
  },
  "location": {
      "displayName": "",
      "locationType": "default",
      "uniqueIdType": "unknown",
      "address": {},
      "coordinates": {}
  },
  "locations": [],
  "recurrence": null,
  "attendees": [
      {
          "type": "required",
          "status": {
              "response": "none",
              "time": "0001-01-01T00:00:00Z"
          },
          "emailAddress": {
              "name": "Terrie Barrera",
              "address": "Terrie@contoso.com"
          }
      },
      {
          "type": "required",
          "status": {
              "response": "none",
              "time": "0001-01-01T00:00:00Z"
          },
          "emailAddress": {
              "name": "Lauren Solis",
              "address": "Lauren@contoso.com"
          }
      }
  ],
  "organizer": {
      "emailAddress": {
          "name": "MOD Administrator",
          "address": "admin@contoso.com"
      }
  },
  "onlineMeeting": null
}

成功的响应由 HTTP 201 Created 响应代码表示,并在响应正文中包括新事件,类似于 仅创建事件 中的响应。 响应不包括任何新创建的扩展属性。

若要查看新建的扩展属性,请 获取通过扩展属性扩展的事件

示例 2:为消息创建多值扩展属性

请求

第二个示例为指定的邮件创建一个多值扩展属性。 扩展属性是 multiValueExtendedProperties 集合中的唯一元素。 请求正文包括扩展属性的如下参数:

  • id,将此属性指定为包含指定 GUID 和名称 Palette 的字符串数组。
  • value,将 Palette 指定为包含 3 个字符串值(["Green", "Aqua", "Blue"])的数组。
PATCH https://graph.microsoft.com/v1.0/me/messages/AAMkAGE1M2_as77AACHsLrBBBA=
Content-Type: application/json

{
  "multiValueExtendedProperties": [
      {
         "id":"StringArray {66f5a359-4659-4830-9070-00049ec6ac6e} Name Palette",
         "value":["Green", "Aqua", "Blue"]
      }
    ]
}

响应

成功的响应由 HTTP 200 OK 响应代码表示,并在响应正文中包括指定的邮件,类似于 更新邮件 中的响应。 响应不包括新创建的扩展属性。

若要查看新建的扩展属性,请 获取通过扩展属性扩展的邮件

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

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('c77f324266ba')/messages/$entity",
    "@odata.etag": "W/\"FwAAABYBVGD/o\"",
    "id": "AAMkADI4YzgwfyKAAA=",
    "createdDateTime": "2023-06-26T15:46:05Z",
    "lastModifiedDateTime": "2023-06-28T23:28:50Z",
    "changeKey": "FwAAGSOkFBVGD/o",
    "categories": [],
    "receivedDateTime": "2023-06-26T15:46:05Z",
    "sentDateTime": "2023-06-26T15:46:02Z",
    "hasAttachments": false,
    "internetMessageId": "<1c55OUTLOOK.COM>",
    "subject": "Undeliverable: Celebrate Thanksgiving",
    "bodyPreview": "Delivery has failed to these recipients or groups:Terrie@contoso.comYour message wasn't delivered because the recipient's email provider rejected it.Diagnostic information for administrators:Generating server: CYYP2AM",
    "importance": "normal",
    "parentFolderId": "AAMkADI4YzgwEMAAA=",
    "conversationId": "AAQkADI4Yzej5xL5tI=",
    "conversationIndex": "AQHZq6PnEvm0g==",
    "isDeliveryReceiptRequested": null,
    "isReadReceiptRequested": false,
    "isRead": false,
    "isDraft": false,
    "webLink": "https://outlook.office365.com/owa/?ItemID=AAMQ50XGSOkFdc5AABVNfyKAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
    "inferenceClassification": "focused",
    "body": {
        "contentType": "html",
        "content": "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body><p><b><font color=\"#000066\" size=\"3\" face=\"Arial\">Delivery has failed to these recipients or groups:</font></b></p><font color=\"#000000\" size=\"2\" face=\"Tahoma\"><p><a href=\"mailto:Terrie@contoso.com\">Terrie@contoso.com</a><br></font><font color=\"#000000\" size=\"3\" face=\"Arial\">Your message wasn't delivered because the recipient's email provider rejected it.<br></font><font color=\"#000000\" size=\"2\" face=\"Tahoma\"><br></p></font><br><br><br><br><br><br><font color=\"#808080\" size=\"2\" face=\"Tahoma\"><p><b>Diagnostic information for administrators:</b></p><p>Generating server: CYYP223MB0786.NAMP223.PROD.OUTLOOK.COM<br></p><p>Terrie@contoso.com<br>Remote server returned '550 5.7.501 Service unavailable. Spam abuse detected from IP range. For more information please go to http://go.microsoft.com/fwlink/?LinkId=526653. S(2017052602) [SJ1P223MB0482.NAMP223.PROD.OUTLOOK.COM 2023-06-26T15:46:02.597Z 08DB747F4B5EA12D]'<br></p><p>Original message headers:</p><pre>Received: from CYYP223MB0786.NAMP223.PROD.OUTLOOK.COM ([fe80::f789:3002:5514:2e9d]) by CYYP223MB0786.NAMP223.PROD.OUTLOOK.COM ([fe80::f789:3002:5514:2e9d%3]) with mapi id 15.20.6521.024; Mon, 26 Jun 2023 15:46:02 +0000MIME-Version: 1.0Content-Type: text/plainDate: Mon, 26 Jun 2023 15:46:02 +0000Message-ID:&lt;CYYP223MB078658B6CCF8BDDCC31FA5E6AC26A@CYYP223MB0786.NAMP223.PROD.OUTLOOK.COM&gt;Subject: Celebrate Thanksgiving</pre></font></body></html>"
    },
    "sender": {
        "emailAddress": {
            "name": "Microsoft Outlook",
            "address": "MicrosoftExchange329e71ec88ae4615bbc36ab6ce41109e@contoso.com"
        }
    },
    "from": {
        "emailAddress": {
            "name": "Microsoft Outlook",
            "address": "MicrosoftExchange329e71ec88ae4615bbc36ab6ce41109e@contoso.com"
        }
    },
    "toRecipients": [
        {
            "emailAddress": {
                "name": "Terrie@contoso.com",
                "address": "Terrie@contoso.com"
            }
        }
    ],
    "ccRecipients": [],
    "bccRecipients": [],
    "replyTo": [],
    "flag": {
        "flagStatus": "notFlagged"
    }
}