Microsoft graph api Microsoft Graph API不再返回名称和lastModifiedDateTime
我一直在使用Microsoft Graph API,直到昨天它还返回了文件Microsoft graph api Microsoft Graph API不再返回名称和lastModifiedDateTime,microsoft-graph-api,onedrive,Microsoft Graph Api,Onedrive,我一直在使用Microsoft Graph API,直到昨天它还返回了文件name和lastModifiedDateTime 但是,现在的响应不包含name或lastModifiedDateTime,并且似乎不再按lastModifiedDateTime排序(原因很明显) 这是我正在使用的端点-https://graph.microsoft.com/v1.0/me/drive/recent?$select=name、id、remoteItem、lastModifiedDateTime、webUr
name
和lastModifiedDateTime
但是,现在的响应不包含name
或lastModifiedDateTime
,并且似乎不再按lastModifiedDateTime
排序(原因很明显)
这是我正在使用的端点-https://graph.microsoft.com/v1.0/me/drive/recent?$select=name、id、remoteItem、lastModifiedDateTime、webUrl&$top=50&$orderBy=lastModifiedDateTime desc
以下是回应:
{
"@odata.type":"#microsoft.graph.driveItem",
"id":"01YGW3HF7E7M4TYF74AZAZBXWG7BXHJDI5",
"remoteItem":{
"createdDateTime":"2020-09-08T09:54:15Z",
"id":"01YGW3HF7E7M4TYF74AZAZBXWG7BXHJDI5",
"lastModifiedDateTime":"2020-09-15T05:18:40Z",
"name":"Document.docx",
"size":11381,
"webDavUrl":"https://firmationpersonal-my.sharepoint.com/personal/utkarsh_firmationpersonal_onmicrosoft_com/Documents/Document.docx",
"webUrl":"https://firmationpersonal-my.sharepoint.com/personal/utkarsh_firmationpersonal_onmicrosoft_com/_layouts/15/Doc.aspx?sourcedoc=%7B3C39FBE4-FC17-4106-90DE-C6F86E748D1D%7D&file=Document.docx&action=default&mobileredirect=true",
"createdBy":{
"user":{
"displayName":"NotAdmin Dalal",
"email":"utkarsh@firmationpersonal.onmicrosoft.com"
}
},
"file":{
"mimeType":"application/vnd.openxmlformats-officedocument.wordprocessingml.document"
},
"fileSystemInfo":{
"createdDateTime":"2020-09-08T09:54:15Z",
"lastModifiedDateTime":"2020-09-15T05:18:40Z",
"lastAccessedDateTime":"2020-09-15T06:57:48Z"
},
"lastModifiedBy":{
"user":{
"displayName":"Utkarsh Dalal",
"email":"utkarshdalal@firmationpersonal.onmicrosoft.com"
}
},
"parentReference":{
"driveId":"b!BqfSC_mYxUKYaPxJ673ZaLB_EByxRr1Jkipu7nqJIUrSVsVcfbmBSbJAp1sPfpJ4",
"driveType":"business",
"id":"01YGW3HF56Y2GOVW7725BZO354PWSELRRZ"
},
"shared":{
},
"sharepointIds":{
"listId":"5cc556d2-b97d-4981-b240-a75b0f7e9278",
"listItemId":"1",
"listItemUniqueId":"3c39fbe4-fc17-4106-90de-c6f86e748d1d",
"siteId":"0bd2a706-98f9-42c5-9868-fc49ebbdd968",
"siteUrl":"https://firmationpersonal-my.sharepoint.com/personal/utkarsh_firmationpersonal_onmicrosoft_com",
"webId":"1c107fb0-46b1-49bd-922a-6eee7a89214a"
}
}
}
更新:我可以通过做一些修改来解决这个问题。响应似乎总是包含remoteItem
,因此我从remoteItem
目录中提取name
和lastModifiedDateTime
。
我还按remoteItem/lastModifiedDateTime
订购,而不仅仅是lastModifiedDateTime
我的Python代码:
endpoint = "https://graph.microsoft.com/v1.0/me/drive/recent?" \
"$select=name,id,remoteItem,lastModifiedDateTime,webUrl" \
"&$top=50&$orderBy=remoteItem/lastModifiedDateTime desc"
response = requests.get(endpoint, headers=header)
events = json.loads(response.content)
for recent_activity in events['value']:
# Merge the remoteItem dict and the recent_activity dict because sometimes the data is nested in remoteItem
recent_activity = {**recent_activity, **recent_activity.get('remoteItem', {})}
activity_modified_datetime = datetime.strptime(recent_activity['lastModifiedDateTime'],
'%Y-%m-%dT%H:%M:%SZ')
name = recent_activity['name']
这只是一个解决办法,直到这个问题得到解决——可能永远都不会解决。上面的查询对我也不起作用。很好的解决方法:)顺便说一句,下面这个查询对我很有用。但是,它告诉我$orderby不受支持。看看这是否有帮助:您还在这里寻求帮助吗?目前,我的变通方法是有效的,但我担心一旦API返回记录的响应,它就会停止工作。