Forum Discussion
Is there an API to read Microsoft forms data
ProtivitiDan - thanks for the reply. Yep - that works. Successfully retrieved JSON-formatted questions and responses - but only after logging in/authenticating in our O365 tenant. I can see that the Forms design page is making AJAX calls to the API, but it looks like it's passing some sort of access tokens in the request headers/cookie. It would be nice if Microsoft would publish some information about this, and allow some kind of persistent access token in the url/path for an API call - as they do when they provide a shared collaboration link.
At this point, I've already created a process to ingest the responses from a downloadable Excel sheet, so there's probably no advantage for me to use the API (since I have to be authenticated before it will work).
Thanks again - appreciate you taking the time to respond.
waltksfc I needed the exact same thing, and thanks to you and ProtivitiDan I was able to figure out the correct path.
If you want to make a custom connector for Forms in Flow, you'll need a way to handle authentication.
- Make a new app registration in Azure AD
- Use https://global.consent.azure-apim.net/redirect as the redirect
- Under Certificates & secrets, create a new client secret and save the value somewhere before closing the window because you won't see it ever again
- Under API permissions, add a permission. For this you'll want to go to the "APIs my organization uses" tab and find Microsoft Forms. Add it as a Delegated permission if you want the logged in user to only access their own forms in Flow. I haven't tried Application permission for Forms, but I imagine it will grant access to everyone's forms.
- If you don't want to have to approve every Delegated permission request, make sure after adding it that you press the "Grant admin consent" button.
- Take note of the Application ID.
- Open up Flow and create a custom connector using the App you just created.
There are a lot of guides out there for how to make one. However, the relevant fields for this connector to work with Forms are:
- Host: forms.office.com
- Base URL: /formapi/api
- Identity Provider: Azure Active Directory
- Client id: your App ID from above
- Client secret: the value of the client secret from above
- Resource URL: https://forms.office.com
- Scope: your permissions from above (I used Forms.Read Responses.Read.All )
When you make the connector definition, you insert any dynamic parameters in curly brackets in the request URL. For example, to make an action that requests all questions that are on a specific form, you'd use https://forms.office.com/formapi/api/forms/{formId}/questions for the URL and then formId will be a parameter that you'd fill in for the Flow's action.
I'm now able to authenticate to make web requests to Forms in a Flow so I know you'll be able to do it, too. Hopefully my little guide helps put you on the correct path!