调用 /me/contacts/{id}/photo 不会返回 eTag



我正在调用me/contacts/{id}/photo,响应与文档中定义的内容不匹配。

根据文档,有两件事与我所看到的不符:

  1. 当联系人没有照片时,它指出您将收到一个空的 json paylod,但是我收到404回复此错误

    Code: ErrorItemNotFound
    Message: The specified object was not found in the store.
    
  2. 当有联系人的照片时,文章指出会有一个@odata.mediaEtag,但是我收到的有效载荷没有。以下是我的回应:

    (*map[string]interface {})(0xc42014a028)((len=5) {
     (string) (len=6) "height": (float64) 360,
     (string) (len=5) "width": (float64) 360,
     (string) (len=14) "@odata.context": (string) (len=243) "https://graph.microsoft.com/v1.0/$metadata#users('REDACTED')/contacts('REDACTED')/photo/$entity",
     (string) (len=23) "@odata.mediaContentType": (string) (len=10) "image/jpeg",
     (string) (len=2) "id": (string) (len=7) "360X360"
    })
    

问题#1不会影响我,因为我可以轻松处理404。我更关心问题#2,因为我想要etag,这样我就可以跟踪图像是否已更改,并且仅在更改后下载它。

我能够设置 OAuth,让 API 正常工作,并按照文档成功下载联系人和照片,所以我不确定我错过了什么。

不同的端点可能返回略有不同的数据(即 /me/photo vs /me/{id}/photo vs /groups/{id}/photo (。您可以确定的唯一属性是由profilePhoto解决方案指定的:

{
  "id": "240X240",
  "height": 240,
  "width": 240
}

您可以使用/me/contacts/{id}?$select=id,lastModifiedDateTimeeTag用于contact本身(在 Outlook 中更改联系人的照片应显示为对联系人的修改(:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('{id}')/contacts(id,lastModifiedDateTime)/$entity",
    "@odata.etag": "W/"EQAAABYAAAAiIsqMbYjsT5e/T7KzowPTAAAYc8Bf"",
    "id": "{id}",
    "lastModifiedDateTime": "2017-09-04T15:54:02Z"
}

最新更新