API to access MS forms

%3CLINGO-SUB%20id%3D%22lingo-sub-1463830%22%20slang%3D%22en-US%22%3EAPI%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1463830%22%20slang%3D%22en-US%22%3E%3CP%3ELooking%20for%20an%20API%20to%20access%20MS%20forms%20and%20pull%20the%20survey%20results%20on%20a%20weekly%20basis.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1463830%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EForms%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMicrosoft%20Forms%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESurvey%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1463847%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1463847%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F699880%22%20target%3D%22_blank%22%3E%40ravipokala%3C%2FA%3E%26nbsp%3Ban%20API%20has%20been%20promised%20for%20Forms%20for%20a%20long%20time%20but%20has%20never%20arrived.%20The%20solution%20is%20therefore%20to%20use%20a%20flow%20in%20Power%20Automate%20to%20save%20each%20form%20response%20to%20a%20list%20in%20SharePoint.%20You%20can%20either%20see%20the%20last%20week's%20responses%20there%20or%20you%20could%20have%20another%20flow%20with%20a%20recurrence%20schedule%20trigger%20set%20to%201%20week.%20That%20would%20get%20the%20items%20created%20in%20the%20list%20in%20the%20last%20week%20and%20do%20whatever%20you%20want%20to%20do%20with%20it.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1715013%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1715013%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F174092%22%20target%3D%22_blank%22%3E%40Rob%20Elliott%3C%2FA%3E%26nbsp%3B%2C%20a%20fairly%20good%20workaround.%20Unfortunately%2C%20Flows%20are%20prone%20to%20failing%20now%20and%20then%20and%20if%20you%20miss%20a%20response%20I%20guess%20there's%20no%20way%20to%20re-fetch%20it%20in%20retrospect%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1717107%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1717107%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F82669%22%20target%3D%22_blank%22%3E%40Martin%20Dreyer%3C%2FA%3E%26nbsp%3Bthe%20response%20will%20still%20be%20in%20the%20spreadsheet%20behind%20the%20form%2C%20so%20you've%20still%20got%20the%20response%20even%20if%20the%20flow%20fails%20for%20some%20reason.%20Over%20the%20last%203%20years%20I've%20found%20Power%20Automate%20to%20be%20very%20reliable%20and%20a%20flows%20will%20very%20rarely%20fail%20once%20you%20have%20properly%20tested%20it.%20Power%20Automate%20is%20far%20more%20reliable%20than%20Forms%20which%2C%20as%20this%20form%20shows%2C%20is%20far%20more%20prone%20to%20errors%20and%20things%20not%20working%20the%20way%20they%20should.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERob%3CBR%20%2F%3ELos%20Gallardos%3CBR%20%2F%3E%3CFONT%20size%3D%222%22%20color%3D%22%23006400%22%3EMicrosoft%20Power%20Automate%20Community%20Super%20User%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1864340%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1864340%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F699880%22%20target%3D%22_blank%22%3E%40ravipokala%3C%2FA%3E%26nbsp%3BI'm%20using%20VBA%20%2B%20SeleniumBasic-2.0.9.0%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EYou%20must%20first%20open%20the%20URL%20%E2%80%9C%3CA%20href%3D%22https%3A%2F%2Fforms.office.com%2FPages%2FDesignPage.aspx%E2%80%9D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fforms.office.com%2FPages%2FDesignPage.aspx%E2%80%9D%3C%2FA%3E%20to%20obtain%20a%20token%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EThen%20you%20can%20call%20%22%3CA%20href%3D%22https%3A%2F%2Fforms.office.com%2Fformapi%2FDownloadExcelFile.ashx%3Fformid%3D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fforms.office.com%2Fformapi%2FDownloadExcelFile.ashx%3Fformid%3D%3C%2FA%3E%22%20%2B%20put%20your%20form%20ID%20Here%20%2B%20%22%26amp%3BtimezoneOffset%3D180%26amp%3BminResponseId%3D1%26amp%3BmaxResponseId%3D1000%22%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EThis%20is%20working%20for%20me%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1940153%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1940153%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F861189%22%20target%3D%22_blank%22%3E%40Leandro_Abade%3C%2FA%3E%20could%20you%20please%20highlight%20on%20how%20did%20you%20obtain%20the%20token%3F%20Did%20you%20have%20to%20register%20in%20app%20in%20Azure%20portal%20or%20by%20some%20other%20way.%20I%20am%20implementing%20something%20similar%20and%20stuck%20with%20the%20first%20pre-requisite%20of%20obtaining%20token.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1940196%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1940196%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F885467%22%20target%3D%22_blank%22%3E%40ssahal%3C%2FA%3E%26nbsp%3B!%20You%20just%20need%20access%20the%20URL%20%E2%80%9C%3CA%20href%3D%22https%3A%2F%2Fforms.office.com%2FPages%2FDesignPage.aspx%E2%80%9D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fforms.office.com%2FPages%2FDesignPage.aspx%E2%80%9D%3C%2FA%3E%2C%20then%20in%20same%20section%20you%20calls%20%22%3CA%20href%3D%22https%3A%2F%2Fforms.office.com%2Fformapi%2FDownloadExcelFile.ashx%3Fformid%3D%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fforms.office.com%2Fformapi%2FDownloadExcelFile.ashx%3Fformid%3D%3C%2FA%3E%22%20%2B%20%5Bput%20your%20form%20ID%20Here%5D%20%2B%20%22%26amp%3BtimezoneOffset%3D180%26amp%3BminResponseId%3D1%26amp%3BmaxResponseId%3D1000%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20token%20is%20automatically%20generated%20in%20the%20site%20section.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESo%2C%20unfortunately%2C%20you%20need%20to%20use%20a%20browser%20to%20use%20the%20API.%20I%20tried%20everything%20to%20get%20files%20using%20code%20and%20nothing%20worked.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20find%20out%20how%20to%20generate%20the%20token%20by%20code%2C%20please%20share%20it%20with%20us!%20Tks%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1940202%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1940202%22%20slang%3D%22en-US%22%3ESure%20thing.%20I%20am%20trying%20to%20generate%20the%20code%20so%20I%20could%20further%20process%20the%20forms%20data%20in%20an%20internal%20workflow.%20Once%20I%20have%20the%20full%20picture%20will%20share%20it%20with%20community%20%3A)%3C%2Fimg%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1964013%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1964013%22%20slang%3D%22en-US%22%3E%3CP%3ELooking%20forward%20to%20seeing%20what%20you%20come%20up%20with.%26nbsp%3B%20Power%20Automate%20is%20often%20just%20to%20picking%20up%20that%20a%20form%20was%20submitted.%26nbsp%3B%20So%20I'm%20looking%20at%20alternatives.%26nbsp%3B%20Thanks.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1978286%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1978286%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F616979%22%20target%3D%22_blank%22%3E%40JimmyStewart%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20need%20a%20Microsoft%20Forms%20API%20so%20that%20I%20can%20programmatically%20create%20new%20forms%2Fpolls%20and%20add%20them%20to%20every%20Microsoft%20Teams%20meeting%2Finvite%20or%20click%20a%20button%20during%20Teams%20meeting%20to%20send%20form%20out%20to%20all%20attendees.%20Each%20meeting%20should%20be%20able%20to%20use%20a%20same%2Fsimilar%20forms%20template%20but%20generate%20a%20new%20form%20so%20that%20CEO%20can%20poll%20attendees%20and%20graph%20responses.%20It%20seems%20this%20capability%20should%20be%20here%20already.%20Would%20be%20nice%20to%20be%20able%20to%20generate%20the%20form%20from%20a%20forms%20template%20on%20the%20fly%20and%20provide%20a%20Microsoft%20Forms%20bot%20to%20deliver%20the%20poll%20to%20the%20user%20in%20an%20interactive%20format.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2162025%22%20slang%3D%22en-US%22%3ERe%3A%20API%20to%20access%20MS%20forms%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2162025%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F419837%22%20target%3D%22_blank%22%3E%40JTAPPS-1%3C%2FA%3Eexactly%20what%20I'm%20trying%20to%20do%20-%20programmatically%20create%20a%20microsoft%20form.%20After%20that%20I%20can%20use%20Logic%20Apps%20for%20example%2C%20but%20the%20creation%20of%20the%20form%20is%20what%20I'm%20missing.%20Simply%20put%20I%20have%20some%20variables%20in%20powershell%20that%20I%20want%20to%20become%20a%20microsoft%20form.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Looking for an API to access MS forms and pull the survey results on a weekly basis.

10 Replies

@ravipokala an API has been promised for Forms for a long time but has never arrived. The solution is therefore to use a flow in Power Automate to save each form response to a list in SharePoint. You can either see the last week's responses there or you could have another flow with a recurrence schedule trigger set to 1 week. That would get the items created in the list in the last week and do whatever you want to do with it.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@RobElliott , a fairly good workaround. Unfortunately, Flows are prone to failing now and then and if you miss a response I guess there's no way to re-fetch it in retrospect?

@Martin Dreyer the response will still be in the spreadsheet behind the form, so you've still got the response even if the flow fails for some reason. Over the last 3 years I've found Power Automate to be very reliable and a flows will very rarely fail once you have properly tested it. Power Automate is far more reliable than Forms which, as this form shows, is far more prone to errors and things not working the way they should.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User

@ravipokala I'm using VBA + SeleniumBasic-2.0.9.0


You must first open the URL “https://forms.office.com/Pages/DesignPage.aspx” to obtain a token


Then you can call "https://forms.office.com/formapi/DownloadExcelFile.ashx?formid=" + put your form ID Here + "&timezoneOffset=180&minResponseId=1&maxResponseId=1000"


This is working for me

@Leandro_Abade could you please highlight on how did you obtain the token? Did you have to register in app in Azure portal or by some other way. I am implementing something similar and stuck with the first pre-requisite of obtaining token.

Hi @ssahal ! You just need access the URL “https://forms.office.com/Pages/DesignPage.aspx”, then in same section you calls "https://forms.office.com/formapi/DownloadExcelFile.ashx?formid=" + [put your form ID Here] + "&timezoneOffset=180&minResponseId=1&maxResponseId=1000"

 

The token is automatically generated in the site section. 

 

So, unfortunately, you need to use a browser to use the API. I tried everything to get files using code and nothing worked.

 

If you find out how to generate the token by code, please share it with us! Tks

Sure thing. I am trying to generate the code so I could further process the forms data in an internal workflow. Once I have the full picture will share it with community :)

Looking forward to seeing what you come up with.  Power Automate is often just to picking up that a form was submitted.  So I'm looking at alternatives.  Thanks.

@JimmyStewart 

 

I need a Microsoft Forms API so that I can programmatically create new forms/polls and add them to every Microsoft Teams meeting/invite or click a button during Teams meeting to send form out to all attendees. Each meeting should be able to use a same/similar forms template but generate a new form so that CEO can poll attendees and graph responses. It seems this capability should be here already. Would be nice to be able to generate the form from a forms template on the fly and provide a Microsoft Forms bot to deliver the poll to the user in an interactive format.

@JTAPPS-1exactly what I'm trying to do - programmatically create a microsoft form. After that I can use Logic Apps for example, but the creation of the form is what I'm missing. Simply put I have some variables in powershell that I want to become a microsoft form.