简体   繁体   English

无法理解或将 Microsoft Graph API HTTP 请求转换为 python 请求

[英]Cannot understand or convert Microsoft Graph API HTTP request to python request

HTTP request mentioned in Microsoft Graph API's documentation found at this link此链接中找到的 Microsoft Graph API 文档中提到的 HTTP 请求

GET /reports/getMailboxUsageDetail(period='{period_value}')

I cannot understand how to incorporate the data mentioned within the round parenthesis我不明白如何合并圆括号中提到的数据

(period='{period_value}')

I tried adding this to query parameters, but it didn't work.我尝试将其添加到查询参数中,但没有奏效。

URL="https://graph.microsoft.com/beta/reports/getMailboxUsageDetail"
    
queryParams={"period":"D7"}
requests.get(URI, params=queryParams)

But, it didn't work.但是,它没有用。

It's actually simpler than you would think.它实际上比你想象的要简单。

You just use the period parameter shown in the round brackets in the URL directly as shown in the documentation.您只需直接使用 URL 中圆括号中显示的周期参数,如文档中所示。

So, if you want to get the same report you're trying as shown in HTTP format:因此,如果您想获得与 HTTP 格式所示相同的报告:

GET /reports/getMailboxUsageDetail(period='{period_value}')

You will use the URL as:您将使用 URL 作为:

reportsURI="https://graph.microsoft.com/beta/reports/getMailboxUsageDetail(period='D7')"


requests.get(reportsURI, headers=authHeaders)

This will give you a report in CSV format.这将为您提供 CSV 格式的报告。 If you want in JSON format, you can use query parameters to mention format如果要 JSON 格式,可以使用查询参数提格式

formatParams = {"format":"application/json"}
requests.get(reportsURI, headers=auth, params=formatParams)

This will give you JSON report.这将为您提供 JSON 报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM