Forum Discussion
Is there an API to read Microsoft forms data
ProtivitiDan Any more information about this? I can get JSON responses as you did, but was not successful getting form responses. Wondering if any documentation has appeared anywhere.
- ProtivitiDanSep 01, 2021Copper Contributor
waltksfc I abandoned my attempts at the time, but looking at it again now I see that I can get info on a specific form with:
https://forms.office.com/formapi/api/forms/{formid}
Then I can get the questions or responses on that form with these:
https://forms.office.com/formapi/api/forms/{formid}/questions https://forms.office.com/formapi/api/forms/{formid}/responses
Get the {formid} from the /forms API call.
- Oh_No_Its_MicrosoftOct 06, 2023Brass Contributor
Unfortunately, now in 2023 the useful calls to forms API to get responses, now just doesn't work.
This works to get ID and other bumpf:
https://forms.office.com/formapi/api/forms
However, to get very useful form and responses:
https://forms.office.com/formapi/api/forms/{form id}
https://forms.office.com/formapi/api/forms/{form id}/reponses
.....using the "form id" from the https://forms.office.com/formapi/api/forms
.... now does not work. I tried all sorts of variants methodically.
I guess Microsoft is desperate for people to get tied into their very old asynch/dynamics infrastructure and go through "PowerAutomate" aka "Flow" instead, to output raw data to an incredibly slow SharePoint list, or an archaic Excel with all the bugs!
Ah! Why is so much in Microsoft-land so disappointing!
Data Scientists want the raw data on-tap!
Why force developers into another inefficient Microsoft infrastructure that's built to tie the customer into a poor solution?
- GideonHuangOct 08, 2023Microsoft
Oh_No_Its_Microsoft Hi Dan, thanks for being interested in using Forms api to get form and response raw data. https://forms.office.com/formapi/api/forms/... are not designed for programmed retrieving data and it would be changed by other scenario needs and infrastructure changes. We're working on publishing microsoft graph api for Forms which will be used for the programmed retrieving data. These Forms Graph APIs will be released in coming monthes.
FYI Ruoying Liang
- waltksfcSep 02, 2021Copper Contributor
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.
- JR2021Sep 27, 2021Brass Contributor
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!
- aura_sanDec 06, 2021Copper Contributor
Hello, ProtivitiDan,
Do you know where can I find API documentation or any kind of guide?
I'm trying to retrieve responses for a specific QuestionId but can't seem to find the combination for the GET request.
Thank you!
- ProtivitiDanDec 06, 2021Copper ContributorSorry @aura_sun, but I don't know of any official documentation from Microsoft yet. JR2021 may have one of the best guides to date in the thread above.
Dan