Is there a solution to collect responses from a shared online MS Form via MS Graph API?
I used the MS Graph API for other purposes i.e. to have access to personal/shared files in OneDrive.
I couldn't find a straight forward solution to have access to the online forms. There are some requests from Microsoft and they responded the option is on the backlog. I was wondering is there an alternative solution to have access to a shared online MS Form via API?

- 389
- 1
- 2
- 14
-
Unfortunately, there is no API to access Microsoft Forms, see [here](https://techcommunity.microsoft.com/t5/microsoft-forms/api-to-access-ms-forms/m-p/1463830). If you mean the files shared in OneDrive, you could refer to the methods [here](https://learn.microsoft.com/en-us/graph/api/resources/drive?view=graph-rest-1.0). – unknown Jan 13 '21 at 08:48
-
As of now there is no support for MS Forms using Microsoft Graph API, there is already a feature request created in the [Microsoft Graph Feedback Forum](https://microsoftgraph.uservoice.com/forums/920506-microsoft-graph-feature-requests/suggestions/32045494-graph-api-to-microsoft-forms). Please upvote it so that the product team may implement it in future. – Shiva Keshav Varma Jan 13 '21 at 08:55
-
@PamelaPeng Yes, I was referring to the same URL when I said there is an ongoing request. I have access to a shared drive already and that's not the case for me now. As the MS online Form responses are not storing on OneDrive I could not use it for this requirement. – Amir Maleki Jan 13 '21 at 09:02
-
@Shiva-MSFTIdentity Thanks for sharing the link, I upvoted the request [Fingers crossed] – Amir Maleki Jan 13 '21 at 09:02
-
Link to Microsoft Graph Feedback Forum seems to be dead. Link to similar feature requests are: [Microsoft Forms Uservoice](https://microsoftforms.uservoice.com/forums/386451-welcome-to-microsoft-forms-suggestion-box/suggestions/32688871-microsoft-graph-api-integration-with-form) and [Microsoft Forms Uservoice](https://microsoftforms.uservoice.com/forums/386451-welcome-to-microsoft-forms-suggestion-box/suggestions/20480830-api-for-microsoft-forms) – m7913d Jun 25 '21 at 08:34
1 Answers
Unfortunately, there is no graph api to do the same.
There are two alternatives I can think of :
Option 1 :
You could maintain your own data source of the form response by using LogicAPP or using Power Automate (Formerly Called as MS Flow)
This trigger will be invoked whenever there is a new response recorded for the form along with the data that has been filled out in the response.
With that you could export this response in a CSV File stored in OneDrive,Sharepoint, Azure storage etc. (appending to already existing response). So that you consume this CSV over the Graph API as and when required.
or add the responses to a Sharepoint Online List as List items. You could get the list items through Graph API.
https://learn.microsoft.com/en-us/graph/api/resources/listitem?view=graph-rest-1.0
Option 2 :
Note : This approach might be suitable if you performing an operation in a non-web application.
Since you are trying to achieve your goal through Python. I thought you could use Selenium for WebBrowser.
The API that fetches the Answer responses is below :
GET https://forms.office.com/formapi/api/<tenantid>/users/<userid>/light/forms('<formid>')/responses?$expand=comments&$top=7&$skip=0
Sample response for the above request :
The catch here is that, there is no means to obtain the access token for the above API at this point of time. (As far as I have researched)
So workaround, that I have done is to make use of the Selenium.
For instance - use the ChromeDriver and Selenium library to automate the below process :
You could refer this article https://www.browserstack.com/guide/python-selenium-to-run-web-automation-test to understand how we can do the browser automation using python-chrome.
Step 1 : Automate the login into https://forms.office.com. This step will create the necessary cookie for the session to access the forms api
Step 2: Now hit the api in same session
GET https://forms.office.com/formapi/api/<tenantid>/users/<userid>/light/forms('<formid>')/responses?$expand=comments&$top=7&$skip=0
and you will get the output as the response :
Which can be assessed & used subsequently for processing.

- 3,811
- 1
- 6
- 9
-
-
Is it possible to automate the login process using an OAuth access or refresh token (i.e. the token that would normally be used to access Microsoft Graph API) without knowing the Office365 password of the user? – m7913d Nov 16 '21 at 10:41
-
1@m7913d I don't think so. The link provided reads httponly cookies from your browser to identify the login. The link is likely just meant to populate data in Microsoft's own web interface, not really meant to be queried directly. This roundabout manner of data access necessitates the use of Selenium webdriver. – Michael Sohnen Feb 13 '23 at 17:27