How to check an Outlook custom property is available via Microsoft Graph

亡梦爱人 提交于 2019-12-10 00:02:54

问题


I added a custom property to an Event using an office.js add-in.

I tried to get that custom property's value using https://graph.microsoft.com/v1.0/me/events/AQMkADU2OWFjYTF..AAAA==?singleValueExtendedProperties($filter=id eq 'String 00020329-0000-0000-C000-000000000046 myCusPropId ') but it is return an error:

{
  "error": {
    "code": "ErrorInvalidProperty",
    "message": "PropertyId values may only be in one of the following formats: 'MapiPropertyType namespaceGuid Name propertyName', 'MapiPropertyType namespaceGuid Id propertyId' or 'MapiPropertyType propertyTag'.",
    "innerError": {
      "request-id": "c57cd272-2c10-4721-b48e-1c27117ea34f",
      "date": "2019-09-27T10:23:03"
    }
  }
}

How do I retrieve myCusPropId?

here is office.js code

const item = Office.context.mailbox.item;
item.loadCustomPropertiesAsync(asyncResult => {
      if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {
        let customProps = asyncResult.value; 
        customProps.set("myCusProp", "google.com");
        customProps.saveAsync(asyncResult => {
          if (asyncResult.status == Office.AsyncResultStatus.Succeeded) {            
             item.loadCustomPropertiesAsync(asyncResult => {
              const customProps = asyncResult.value;
              const myCusProp= customProps.get("myCusProp"); 
            })
          }});}});

回答1:


You're missing the $expand query param and your id is malformed. The correct call phototype looks like this:

GET /me/events/{id}?$expand=singleValueExtendedProperties($filter=id eq '{prop_id}')

Note the ?$expand=singleValueExtendedProperties rather than ?singleValueExtendedProperties.

For the property itself, you're missing the Name segment:

String {00020329-0000-0000-C000-000000000046} Name myCusPropId

So the final URI would be:

https://graph.microsoft.com/v1.0/me/events/AQMkADU2OWFjYTF..AAAA==?$expand=singleValueExtendedProperties($filter=id eq 'String {00020329-0000-0000-C000-000000000046} Name myCusPropId')



来源:https://stackoverflow.com/questions/58132732/how-to-check-an-outlook-custom-property-is-available-via-microsoft-graph

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!