

Report on Microsoft Forms activities via the Graph API
source link: https://www.michev.info/Blog/Post/4402/report-on-microsoft-forms-activities-via-the-graph-api
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Report on Microsoft Forms activities via the Graph API
As noted in Roadmap item #109557, Microsoft just released the set of Graph API endpoint for Forms usage reports. The Forms activity report has been available for a while now under the Reports > Usage > Forms section of the Microsoft 365 admin center, so having the corresponding APIs released is a bit overdue. For the time being, the set of endpoints is only available under the /beta version, even though the Roadmap item designates them as GA.
The official documentation has not been updated yet, however the $metadata document gives us all the information we need. A total of four endpoints have been introduced, using the familiar schema – two giving us the total count of activities and the count of activities per user, and two giving us detailed breakdown either for a specific date or a predetermined period of time. Below is the corresponding metadata exert:
< Function Name= "getFormsUserActivityCounts" IsBound= "true" > < Parameter Name= "reportRoot" Type= "graph.reportRoot" /> < Parameter Name= "period" Type= "Edm.String" Nullable= "false" Unicode= "false" /> <ReturnType Type= "Edm.Stream" Nullable= "false" /> </ Function > < Function Name= "getFormsUserActivityUserCounts" IsBound= "true" > < Parameter Name= "reportRoot" Type= "graph.reportRoot" /> < Parameter Name= "period" Type= "Edm.String" Nullable= "false" Unicode= "false" /> <ReturnType Type= "Edm.Stream" Nullable= "false" /> </ Function > < Function Name= "getFormsUserActivityUserDetail" IsBound= "true" > < Parameter Name= "reportRoot" Type= "graph.reportRoot" /> < Parameter Name= "date" Type= "Edm.Date" Nullable= "false" /> <ReturnType Type= "Edm.Stream" Nullable= "false" /> </ Function > < Function Name= "getFormsUserActivityUserDetail" IsBound= "true" > < Parameter Name= "reportRoot" Type= "graph.reportRoot" /> < Parameter Name= "period" Type= "Edm.String" Nullable= "false" Unicode= "false" /> <ReturnType Type= "Edm.Stream" Nullable= "false" /> </ Function > |
With this information at hand, we can query the corresponding Graph API endpoints and fetch the reports. For example, in order to get the total activities count, we can query the getFormsUserActivityCounts endpoint and provide the requested period value, i.e. period=’D90′:
GET https://graph.microsoft.com/beta/reports/getFormsUserActivityCounts(period= 'D90' ) |
The output will be returned as JSON by default, but you can also request a CSV file if needed. The corresponding $format query parameter controls this behavior ($format=text/csv for the CSV file; $format=application/json for JSON).
Similarly, to get the detailed breakdown per user, we can use the getFormsUserActivityUserDetail endpoint, either for a given period or a specific date. As customary with other reports, the set of users returned will include accounts corresponding to shared mailboxes, resource mailboxes, and so on, so you might have to trim it a bit after fetching the data.
GET https://graph.microsoft.com/beta/reports/getFormsUserActivityUserDetail(period= 'D90' ) |
The set of properties returned includes the reportRefreshDate, each user’s identifier (userPrincipalName), lastActivityDate for the user within the Forms app, and the count of created forms (createdCount) and form responses (respondedCount) for the requested period (reportPeriod), encapsulated in the formsUsageUserDetailsByPeriod property. Here’s an example JSON output from the Graph explorer:
And that’s pretty much all there is to it. Hopefully, we will see the set of Forms reports endpoint available under /v1.0 sometime this year
Recommend
-
10
Limiting access to SharePoint Online resources via the Graph API Just as I was finishing up my article on suppo...
-
11
Checking Microsoft 365 Group resources via the Graph API Ever since the release of Office 365 Groups (now Microsoft 365 Groups), the marketing and product folks at Microsoft have been nagging customers to switch t...
-
9
Querying the B2BManagementPolicy settings via (legacy) Graph API Here’s another one in the series “I blog so I don’t forget about this”, this time related to the B2BManagementPolicy in Azure AD. For whatever reaso...
-
10
Bulk enable specific services via the Graph API Continuing the rework of older scripts and snippets to use Microsoft Graph PowerShell SDK
-
11
Friendships form via shared context, not shared activities
-
6
Managing SharePoint Online tenant settings via the Graph API While the Graph API has a good coverage of “end user” endpoints, which cover most client scenarios, the “admin” part of the experience remains largely non-ex...
-
14
Manage directory synchronization settings via the Graph API After years of unsuccessful attempts to deprecate the good old MSOnline PowerShell module and subsequent postponements for its end of life, Microsoft seems to...
-
5
Report on Azure AD group members via the Graph API As I continue updating my PowerShell script samples to the latest and greatest, it’s time to revamp the Group membership script. The task is simple – provide an easy w...
-
6
Managing Azure AD Recommendations via the Graph API Azure Active Directory Recommendations
-
5
Reporting on user provisioning errors via the Graph API We’ve
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK