首页 > 解决方案 > 为什么即使请求详细信息相同,MS 图形浏览器和我的 python 请求结果也会不同

问题描述

我正在使用 ms-graph user:findMeetingTimesapi 来检索给定用户的免费会议时间。

我使用https://developer.microsoft.com/en-us/graph/graph-explorerwithPOST https://graph.microsoft.com/v1.0/me/findMeetingTimes检索免费会议时间,我使用 Pythonrequests模块检索具有相同参数的相同信息,但使用 python requeststhen in调用时结果不正确graph-explorer。访问权限在文档中提供。对我来说,从 Python api 调用 rest 时它看起来"meetingDuration": "PT1H"不起作用,然后它默认每 30 分钟返回一次,如user:findMeetingTimes文档中所述。有人遇到过这个问题吗?

唯一的区别是start/end时间。我预计start/end会是 1h (设置为"meetingDuration": "PT1H"),但默认情况下它会返回 30mins

如果我使用graph-explorerMicrosoft 提供的测试,这不是问题,但是当我从我的 Python api 调用时,问题就出现了......

请求正文:

{
  "attendees": [
    {
      "emailAddress": {
        "address": "<user-email>",
        "name": "<user>"
      },
      "type": "Required"
    }
  ],
  "timeConstraint": {
    "timeslots": [
      {
        "start": {
          "dateTime": "2019-01-24T19:00",
          "timeZone": "AUS Eastern Standard Time"
        },
        "end": {
          "dateTime": "2019-01-24T21:00",
          "timeZone": "AUS Eastern Standard Time"
        }
      }
    ]
  },
  "meetingDuration": "PT1H"
  }

请求标头:

 {'return-client-request-id': 'true', 'client-request-id': '<client-id>', 'Authorization': 'Bearer <token>', 'Content-Type': 'application/json', 'Prefer': 'outlook.timezone="AUS Eastern Standard Time"', 'Accept': 'application/json', 'User-Agent': 'appointments/1.0'}

我期望这样的结果:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.meetingTimeSuggestionsResult",
    "emptySuggestionsReason": "",
    "meetingTimeSuggestions": [
        {
            "confidence": 100,
            "organizerAvailability": "free",
            "meetingTimeSlot": {
                "start": {
                    "dateTime": "2019-01-24T19:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                },
                "end": {
                    "dateTime": "2019-01-24T20:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                }
            },
            "attendeeAvailability": [],
            "locations": []
        },
        {
            "confidence": 100,
            "organizerAvailability": "free",
            "meetingTimeSlot": {
                "start": {
                    "dateTime": "2019-01-24T20:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                },
                "end": {
                    "dateTime": "2019-01-24T21:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                }
            },
            "attendeeAvailability": [],
            "locations": []
        }
    ]
}

但是使用 Python API 我得到了这个:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.meetingTimeSuggestionsResult",
    "emptySuggestionsReason": "",
    "meetingTimeSuggestions": [
        {
            "attendeeAvailability": [],
            "confidence": 100.0,
            "locations": [],
            "meetingTimeSlot": {
                "end": {
                    "dateTime": "2019-01-24T20:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                },
                "start": {
                    "dateTime": "2019-01-24T19:30:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                }
            },
            "organizerAvailability": "free"
        },
        {
            "attendeeAvailability": [],
            "confidence": 100.0,
            "locations": [],
            "meetingTimeSlot": {
                "end": {
                    "dateTime": "2019-01-24T20:30:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                },
                "start": {
                    "dateTime": "2019-01-24T20:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                }
            },
            "organizerAvailability": "free"
        },
        {
            "attendeeAvailability": [],
            "confidence": 100.0,
            "locations": [],
            "meetingTimeSlot": {
                "end": {
                    "dateTime": "2019-01-24T21:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                },
                "start": {
                    "dateTime": "2019-01-24T20:30:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                }
            },
            "organizerAvailability": "free"
        },
        {
            "attendeeAvailability": [],
            "confidence": 100.0,
            "locations": [],
            "meetingTimeSlot": {
                "end": {
                    "dateTime": "2019-01-24T21:30:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                },
                "start": {
                    "dateTime": "2019-01-24T21:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                }
            },
            "organizerAvailability": "free"
        },
        {
            "attendeeAvailability": [],
            "confidence": 100.0,
            "locations": [],
            "meetingTimeSlot": {
                "end": {
                    "dateTime": "2019-01-24T22:00:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                },
                "start": {
                    "dateTime": "2019-01-24T21:30:00.0000000",
                    "timeZone": "AUS Eastern Standard Time"
                }
            },
            "organizerAvailability": "free"
        }
    ]
}

我在图形浏览器中检查了标题

Host: graph.microsoft.com
User-Agent: <mozilla>
Accept: application/json, text/plain, */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Referer: https://developer.microsoft.com/en-us/graph/graph-explorer
Content-type: application/json
Authorization: Bearer <token>
Content-Length: 716
Origin: https://developer.microsoft.com
Connection: keep-alive

和我请求中的标题:

{
  "Accept": "application/json",
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json",
  "Prefer": "outlook.timezone=AUS Eastern Standard Time",
  "User-Agent": "myApp/1.0",
  "client-request-id": "<client-id>",
  "return-client-request-id": "true"
}

标签: pythonrestmicrosoft-graph-apioutlook-restapi

解决方案


推荐阅读