如何解决Microsoft Graph中的时间轴活动
我正在检查Windows 10的“活动API”。我能够将活动插入到图形中并得到确认,但是当我尝试读出活动时,该活动不存在。在Windows上,我也没有我所期望的改变。
我创建了一个应用,并使用以下网址登录:https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=MY_ID&scope=openid profile UserActivity.ReadWrite.CreatedByApp&response_type=code&redirect_uri=http://localhost:3000/auth/callback&state=4711
登录后,我获取代码并按如下方式获取我的不记名令牌:
POST https://login.microsoftonline.com/common/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded
client_id=MY_ID&client_secret=MY_SECRET&grant_type=authorization_code&code=M.R3_BAY.12345678-1234-1234-1234-123456789abc&redirect_uri=http://localhost:3000/auth/callback
这按预期工作。然后,我要插入这样的活动:
PUT https://graph.microsoft.com/v1.0/me/activities/%2Ftest123
Authorization: Bearer MY_BEARER_TOKEN
Content-type: application/json
{
"appActivityId": "/test123","activitySourceHost": "https://rks.app","userTimezone": "Europe/Berlin","appDisplayName": "My Test App","activationUrl": "https://rks.app/?active","contentUrl": "https://rks.app/?content","fallbackUrl": "https://rks.app/?fallback","contentInfo": {
"@context": "https://schema.org","@type": "Article","author": "rekire","name": "Testing all the shit"
},"visualElements": {
"attribution": {
"iconUrl": "https://i.stack.imgur.com/UPzx8.png","alternateText": "rekire","addImageQuery": false
},"description": "Description why I am great!","backgroundColor": "#ff0000","displayText": "Displaying that I am great","content": {
"$schema": "https://adaptivecards.io/schemas/adaptive-card.json","type": "AdaptiveCard","body": [
{
"type": "TextBlock","text": "Fancy shit!"
}
]
}
}
}
我的api调用有问题吗?当我按 Windows + Tab 时,我看不到它应该在那里吗?
解决方法
我发现我错过添加一个historyItems
节点。这是一个示例:
"historyItems": [
{
"userTimezone": "Europe/Berlin","startedDateTime": "2020-09-19T16:01:02.123Z","lastActiveDateTime": "2020-09-21T08:04:22.123Z"
}
]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。