Harsh Math
Harsh Math

Reputation: 473

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

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.

Upvotes: 1

Views: 428

Answers (1)

chief dot101
chief dot101

Reputation: 111

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.

So, if you want to get the same report you're trying as shown in HTTP format:

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

You will use the URL as:

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


requests.get(reportsURI, headers=authHeaders)

This will give you a report in CSV format. If you want in JSON format, you can use query parameters to mention format

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

This will give you JSON report.

Upvotes: 2

Related Questions