1

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.

6
  • Where is the header? Commented Apr 20, 2021 at 14:44
  • it's just a sample. i added proper auth headers in my original request. i am able to get data for other requests, just not this one. Commented Apr 20, 2021 at 14:45
  • So you code looks like requests.get(URI,headers=headers params=queryParams)? what is the respond code you get? Commented Apr 20, 2021 at 14:49
  • "error": { "code": "BadRequest", "message": "Resource not found for the segment 'getMailboxUsageDetail'.", Commented Apr 26, 2021 at 14:00
  • I think you should use single quotes around the queryParams: {'period':'D7'}. Also there's a sample request here: learn.microsoft.com/en-us/graph/api/…. Does this help? Commented Apr 27, 2021 at 6:15

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.