我正在呼叫me/contacts/{id}/photo
,响应与defined in the docs不匹配。
根据文档,有两件事与我所看到的不符:
当联系人没有照片时,它会指出您将收到一个空的json薪水,但是我收到404
响应,并返回了此错误
Code: ErrorItemNotFound
Message: The specified object was not found in the store.
当有联系人照片时,文章指出将有@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能够正常运行,并能够根据文档成功下载联系人和照片,所以我不确定自己缺少什么。
答案 0 :(得分:0)
不同的端点可能返回略有不同的数据(即/me/photo
与/me/{id}/photo
与/groups/{id}/photo
)。您可以确定的唯一属性是profilePhoto
重新指定的资源:
{
"id": "240X240",
"height": 240,
"width": 240
}
您可以使用eTag
将contact
用于/me/contacts/{id}?$select=id,lastModifiedDateTime
本身(在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"
}