Forum Discussion

Doranarni's avatar
Doranarni
Icon for Microsoft rankMicrosoft
Nov 28, 2018

Is there an API to read Microsoft forms data

is it possible to read Microsoft forms submitted data . we are exploring concepts and would like to get data of submitted forms using API.

  • Damien_Rosario's avatar
    Damien_Rosario
    Silver Contributor

    Until the long awaited API is released, a short term workaround could be to use Power Automate (formerly Microsoft Flow) to trigger when a new form is submitted, and to save the results into a SharePoint list, or Excel file, etc and to manipulate the data from there.

     

    Power Automate puts some pretty cool options for not only extracting the Forms data but to also initiate other actions that can benefit you (e.g. put the results into a Word doc template and email to someone, etc).

     

    Well worth a look!

     

    Cheers

    Damien  

    • RobElliott's avatar
      RobElliott
      Silver Contributor

      Damien_Rosario  I wouldn't call using Power Automate a workaround; it's designed for the job!  And the integrations, as you've pointed out, with Email, SharePoint, Forms, Excel etc etc work beautifully.

      Rob
      Los Gallardos
      Microsoft Power Automate Community Super User

      • Damien_Rosario's avatar
        Damien_Rosario
        Silver Contributor

        Hi RobElliott 

         

        Very true, the capability is there with some extra steps to capture the initial submission, but I reckon my suggestion is a workaround until the API comes out as there'll be more direct ways to get data out of Forms with its release.

         

        Cheers

        Damien

    • ProtivitiDan's avatar
      ProtivitiDan
      Copper Contributor
      There now appears to be an API for getting some information from Microsoft Forms at https://forms.office.com/formapi/api. I'm not sure when it was released, and I'm having trouble finding documentation on it, but I can at least pull some information in my browser this way. After going to https://forms.office.com/ to login (which sets a token in the browser), I can then browse to https://forms.office.com/formapi/api to get a list of operations or to a specific operation like https://forms.office.com/formapi/api/forms to get a list of my Forms.
      • waltksfc's avatar
        waltksfc
        Copper Contributor

        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.

  • johndpalm's avatar
    johndpalm
    Brass Contributor

    It appears the URL format of the undocumented Forms API has changed.  When I used the examples from earlier posts, they returned a 404.  This worked for me:

     

     

    # Get personal Forms
    https://forms.office.com/formapi/api/forms
    
    # Get all Forms for a Microsoft 365 Group
    https://forms.office.com/formapi/api/{tenantId}/groups/{groupId}/forms
    
    # Get the details for a group form
    https://forms.office.com/formapi/api/{tenantId}/groups/{groupId}/forms('{formId}')
    
    # Get the questions from a group form
    https://forms.office.com/formapi/api/{tenantId}/groups/{groupId}/forms('{formId}')/questions
    
    # Get the responses to a group form
    https://forms.office.com/formapi/api/{tenantId}/groups/{groupId}/forms('{formId}')/responses

     

     

     

    • johndpalm's avatar
      johndpalm
      Brass Contributor

      johndpalm Doranarni waltksfc 

      Here's the Swagger I'm using to run a Power Automate custom connector for the 4 GET requests I mentioned above:

       

      swagger: '2.0'
      info:
        title: Default title
        description: A custom connector for Microsoft Forms API
        version: '1.0'
      host: forms.office.com
      basePath: /formapi/api
      schemes:
        - https
      consumes: []
      produces: []
      paths:
        /{Tenant Id}/groups/{Group Id}/forms:
          get:
            responses:
              default:
                description: default
                schema:
                  type: object
                  properties:
                    value:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            type: string
                            description: id
                            title: ''
                            x-ms-visibility: internal
                          title:
                            type: string
                            description: The title of the form
                            title: Title
                            x-ms-visibility: important
                          thankYouMessage:
                            type: string
                            description: >-
                              The thank you message displayed when completing the
                              form.
                            title: Thank you message
                            x-ms-visibility: important
                          type:
                            type: string
                            description: 'The type of form: form or quiz'
                            title: Type
                            x-ms-visibility: important
                          defaultLanguage:
                            type: string
                            description: defaultLanguage
                            title: ''
                            x-ms-visibility: internal
                          dataClassificationLevel:
                            type: string
                            description: dataClassificationLevel
                            title: ''
                            x-ms-visibility: internal
                          formsProRTTitle:
                            type: string
                            description: formsProRTTitle
                            title: ''
                            x-ms-visibility: internal
                          formsProRTDescription:
                            type: string
                            description: formsProRTDescription
                            title: ''
                            x-ms-visibility: internal
                          meetingId:
                            type: string
                            description: meetingId
                            title: ''
                            x-ms-visibility: internal
                          formsInsightsInfo:
                            type: string
                            description: formsInsightsInfo
                            title: ''
                            x-ms-visibility: internal
                          responseThresholdCount:
                            type: string
                            description: ''
                            title: Response threshold count
                            x-ms-visibility: advanced
                          inviteExpiryDays:
                            type: string
                            description: inviteExpiryDays
                            title: ''
                            x-ms-visibility: internal
                          collectionId:
                            type: string
                            description: collectionId
                            title: ''
                            x-ms-visibility: internal
                          TenantSwitches:
                            type: integer
                            format: int32
                            description: TenantSwitches
                            title: ''
                            x-ms-visibility: internal
                          PrivacyUrl:
                            type: string
                            description: PrivacyUrl
                            title: ''
                            x-ms-visibility: internal
                          description:
                            type: string
                            description: Form description
                            title: Description
                            x-ms-visibility: important
                          onlineSafetyLevel:
                            type: integer
                            format: int32
                            description: onlineSafetyLevel
                            title: ''
                            x-ms-visibility: internal
                          reputationTier:
                            type: integer
                            format: int32
                            description: ''
                            title: Reputation tier
                            x-ms-visibility: advanced
                          tableId:
                            type: string
                            description: tableId
                            title: ''
                            x-ms-visibility: internal
                          otherInfo:
                            type: string
                            description: Other information such as the name of the theme used.
                            title: Other information
                          status:
                            type: string
                            description: The status of the form
                            title: Status
                            x-ms-visibility: important
                          category:
                            type: string
                            description: category
                            title: ''
                            x-ms-visibility: internal
                          predefinedResponses:
                            type: string
                            description: predefinedResponses
                            title: ''
                            x-ms-visibility: internal
                          createdBy:
                            type: string
                            description: The GUID of the user who created the form
                            title: Created by
                          XlFileUnSynced:
                            type: boolean
                            description: XlFileUnSynced
                            title: ''
                            x-ms-visibility: internal
                            enum:
                              - ''
                              - 'true'
                              - 'false'
                          mfpBranchingData:
                            type: string
                            description: mfpBranchingData
                            title: ''
                            x-ms-visibility: internal
                          email address removed for privacy reasons:
                            type: string
                            description: email address removed for privacy reasons
                            title: ''
                            x-ms-visibility: internal
                          rowCount:
                            type: integer
                            format: int32
                            description: ''
                            title: Row count
                            x-ms-visibility: advanced
                          progressBarEnabled:
                            type: string
                            description: ''
                            title: Progress bar enabled
                            x-ms-visibility: advanced
                          trackingId:
                            type: string
                            description: ''
                            title: Tracking Id
                            x-ms-visibility: advanced
                          xlWorkbookId:
                            type: string
                            description: xlWorkbookId
                            title: ''
                            x-ms-visibility: internal
                          xlTableId:
                            type: string
                            description: xlTableId
                            title: ''
                            x-ms-visibility: internal
                          xlExportingTag:
                            type: string
                            properties:
                              Status:
                                type: string
                                description: Status
                                title: ''
                                x-ms-visibility: internal
                              ExportedRowCount:
                                type: integer
                                format: int32
                                description: ExportedRowCount
                                title: ''
                                x-ms-visibility: internal
                            description: xlExportingTag
                          ShareToken:
                            type: string
                            description: ShareToken
                            title: ''
                            x-ms-visibility: internal
                          localeList:
                            type: array
                            items: {}
                            description: localeList
                          logo:
                            type: object
                            properties:
                              altText:
                                type: string
                                description: altText
                                title: ''
                                x-ms-visibility: internal
                              contentType:
                                type: string
                                description: contentType
                                title: ''
                                x-ms-visibility: internal
                              fileIdentifier:
                                type: string
                                description: fileIdentifier
                                title: ''
                                x-ms-visibility: internal
                              height:
                                type: string
                                description: height
                                title: ''
                                x-ms-visibility: internal
                              originalFileName:
                                type: string
                                description: originalFileName
                                title: ''
                                x-ms-visibility: internal
                              resourceId:
                                type: string
                                description: resourceId
                                title: ''
                                x-ms-visibility: internal
                              resourceUrl:
                                type: string
                                description: resourceUrl
                                title: ''
                                x-ms-visibility: internal
                              width:
                                type: string
                                description: width
                                title: ''
                                x-ms-visibility: internal
                              size:
                                type: string
                                description: size
                                title: ''
                                x-ms-visibility: internal
                            description: logo
                          header:
                            type: object
                            properties:
                              altText:
                                type: string
                                description: altText
                                title: ''
                                x-ms-visibility: internal
                              contentType:
                                type: string
                                description: contentType
                                title: ''
                                x-ms-visibility: internal
                              fileIdentifier:
                                type: string
                                description: fileIdentifier
                                title: ''
                                x-ms-visibility: internal
                              height:
                                type: string
                                description: height
                                title: ''
                                x-ms-visibility: internal
                              originalFileName:
                                type: string
                                description: originalFileName
                                title: ''
                                x-ms-visibility: internal
                              resourceId:
                                type: string
                                description: resourceId
                                title: ''
                                x-ms-visibility: internal
                              resourceUrl:
                                type: string
                                description: resourceUrl
                                title: ''
                                x-ms-visibility: internal
                              width:
                                type: string
                                description: width
                                title: ''
                                x-ms-visibility: internal
                              size:
                                type: string
                                description: size
                                title: ''
                                x-ms-visibility: internal
                            description: header
                          background:
                            type: object
                            properties:
                              altText:
                                type: string
                                description: altText
                                title: ''
                                x-ms-visibility: internal
                              contentType:
                                type: string
                                description: contentType
                                title: ''
                                x-ms-visibility: internal
                              fileIdentifier:
                                type: string
                                description: fileIdentifier
                                title: ''
                                x-ms-visibility: internal
                              height:
                                type: string
                                description: height
                                title: ''
                                x-ms-visibility: internal
                              originalFileName:
                                type: string
                                description: originalFileName
                                title: ''
                                x-ms-visibility: internal
                              resourceId:
                                type: string
                                description: resourceId
                                title: ''
                                x-ms-visibility: internal
                              resourceUrl:
                                type: string
                                description: resourceUrl
                                title: ''
                                x-ms-visibility: internal
                              width:
                                type: string
                                description: width
                                title: ''
                                x-ms-visibility: internal
                              size:
                                type: string
                                description: size
                                title: ''
                                x-ms-visibility: internal
                            description: background
                          FileUploadFormInfo:
                            type: string
                            description: FileUploadFormInfo
                            title: ''
                            x-ms-visibility: internal
                          modifiedDate:
                            type: string
                            description: When the form was last modified
                            title: Modified date
                          createdDate:
                            type: string
                            description: When the form was created
                            title: Created date
                          version:
                            type: string
                            description: The version of the form
                            title: Version
                          ownerId:
                            type: string
                            description: The user GUID of the owner
                            title: Owner Id
                          ownerTenantId:
                            type: string
                            description: ownerTenantId
                            title: Owner tenant Id
                            x-ms-visibility: internal
                          softDeleted:
                            type: integer
                            format: int32
                            description: softDeleted
                            title: ''
                            x-ms-visibility: internal
                          flags:
                            type: integer
                            format: int32
                            description: flags
                            title: ''
                            x-ms-visibility: internal
                          emailReceiptEnabled:
                            type: string
                            description: emailReceiptEnabled
                            title: ''
                            x-ms-visibility: internal
                      description: value
            summary: Get all forms for a group
            operationId: GetFormsByGroup
            description: Get all Microsoft Forms for a Microsoft 365 Group
            parameters:
              - name: Tenant Id
                in: path
                required: true
                type: string
              - name: Group Id
                in: path
                required: true
                type: string
        /{Tenant Id}/groups/{Group Id}/forms('{Form Id}'):
          get:
            responses:
              default:
                description: default
                schema: {}
            summary: Get form details
            description: Get details about a Microsoft Forms form
            operationId: GetFormDetails
            parameters:
              - name: Tenant Id
                in: path
                required: true
                type: string
              - name: Group Id
                in: path
                required: true
                type: string
              - name: Form Id
                in: path
                required: true
                type: string
        /{Tenant Id}/groups/{Group Id}/forms('{Form Id}')/questions:
          get:
            responses:
              default:
                description: default
                schema:
                  type: object
                  properties:
                    '@odata.context':
                      type: string
                      description: '@odata.context'
                      title: ''
                      x-ms-visibility: internal
                    value:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            type: string
                            description: id
                            title: Id
                          title:
                            type: string
                            description: title
                            title: Title
                            x-ms-visibility: important
                          order:
                            type: number
                            format: double
                            description: order
                            title: Order
                          type:
                            type: string
                            description: type
                            title: Type
                            x-ms-visibility: important
                          required:
                            type: boolean
                            description: required
                            title: Required
                            enum:
                              - ''
                              - 'true'
                              - 'false'
                          questionInfo:
                            type: string
                            properties:
                              Choices:
                                type: array
                                items:
                                  type: object
                                  properties:
                                    Description:
                                      type: string
                                      description: Description
                                    IsMathOption:
                                      type: boolean
                                      description: IsMathOption
                                    BranchInfo:
                                      type: object
                                      properties:
                                        TargetQuestionId:
                                          type: string
                                          description: TargetQuestionId
                                        ToTheEnd:
                                          type: boolean
                                          description: ToTheEnd
                                      description: BranchInfo
                                    IsGenerated:
                                      type: boolean
                                      description: IsGenerated
                                    IsAnswerKey:
                                      type: boolean
                                      description: IsAnswerKey
                                description: Choices
                              ChoiceType:
                                type: integer
                                format: int32
                                description: ChoiceType
                                title: Choice type
                              AllowOtherAnswer:
                                type: boolean
                                description: AllowOtherAnswer
                                title: Allow other answer
                                enum:
                                  - ''
                                  - 'true'
                                  - 'false'
                              OptionDisplayStyle:
                                type: string
                                description: OptionDisplayStyle
                                title: Option display style
                            description: questionInfo
                          isQuiz:
                            type: boolean
                            description: isQuiz
                          groupId:
                            type: string
                            description: groupId
                            title: ''
                            x-ms-visibility: internal
                          defaultValue:
                            type: string
                            description: defaultValue
                            title: ''
                            x-ms-visibility: internal
                          modifiedDate:
                            type: string
                            description: modifiedDate
                            title: Modified date
                          status:
                            type: string
                            description: status
                            title: Status
                          subtitle:
                            type: string
                            description: subtitle
                            title: Subtitle
                          allowMultipleValues:
                            type: string
                            description: allowMultipleValues
                            title: ''
                            x-ms-visibility: internal
                          titleHasPhishingKeywords:
                            type: boolean
                            description: titleHasPhishingKeywords
                            title: ''
                            x-ms-visibility: internal
                            enum:
                              - ''
                              - 'true'
                              - 'false'
                          subtitleHasPhishingKeywords:
                            type: boolean
                            description: subtitleHasPhishingKeywords
                            title: ''
                            x-ms-visibility: internal
                            enum:
                              - ''
                              - 'true'
                              - 'false'
                          questionTagForIntelligence:
                            type: string
                            description: questionTagForIntelligence
                            title: ''
                            x-ms-visibility: internal
                          isFromSuggestion:
                            type: boolean
                            description: isFromSuggestion
                          insightsInfo:
                            type: string
                            description: insightsInfo
                            title: ''
                            x-ms-visibility: internal
                          formsProRTQuestionTitle:
                            type: string
                            description: formsProRTQuestionTitle
                            title: ''
                            x-ms-visibility: internal
                          formsProRTSubtitle:
                            type: string
                            description: formsProRTSubtitle
                            title: ''
                            x-ms-visibility: internal
                          allowCustomChoice:
                            type: string
                            description: allowCustomChoice
                            title: ''
                            x-ms-visibility: internal
                          trackingId:
                            type: string
                            description: trackingId
                            title: Tracking Id
                          image:
                            type: object
                            properties:
                              altText:
                                type: string
                                description: altText
                                title: ''
                                x-ms-visibility: internal
                              contentType:
                                type: string
                                description: contentType
                                title: ''
                                x-ms-visibility: internal
                              fileIdentifier:
                                type: string
                                description: fileIdentifier
                                title: ''
                                x-ms-visibility: internal
                              height:
                                type: string
                                description: height
                                title: ''
                                x-ms-visibility: internal
                              originalFileName:
                                type: string
                                description: originalFileName
                                title: ''
                                x-ms-visibility: internal
                              resourceId:
                                type: string
                                description: resourceId
                                title: ''
                                x-ms-visibility: internal
                              resourceUrl:
                                type: string
                                description: resourceUrl
                                title: ''
                                x-ms-visibility: internal
                              width:
                                type: string
                                description: width
                                title: ''
                                x-ms-visibility: internal
                              size:
                                type: string
                                description: size
                                title: ''
                                x-ms-visibility: internal
                            description: image
                          fileUploadSPOInfo:
                            type: string
                            description: fileUploadSPOInfo
                            title: ''
                            x-ms-visibility: internal
                      description: value
            summary: Get form questions
            description: Get the questions from a Microsoft Forms form
            operationId: GetFormQuestions
            parameters:
              - name: Tenant Id
                in: path
                required: true
                type: string
              - name: Group Id
                in: path
                required: true
                type: string
              - name: Form Id
                in: path
                required: true
                type: string
        /{Tenant Id}/groups/{Group Id}/forms('{Form Id}')/responses:
          get:
            responses:
              default:
                description: default
                schema:
                  type: object
                  properties:
                    '@odata.context':
                      type: string
                      description: '@odata.context'
                      title: ''
                      x-ms-visibility: internal
                    value:
                      type: array
                      items:
                        type: object
                        properties:
                          id:
                            type: integer
                            format: int32
                            description: id
                            title: Id
                          startDate:
                            type: string
                            description: startDate
                            title: Start date
                          submitDate:
                            type: string
                            description: submitDate
                            title: Submit date
                          responder:
                            type: string
                            description: responder
                            title: Responder
                          responderName:
                            type: string
                            description: responderName
                            title: Responder name
                          answers:
                            type: string
                            items:
                              type: object
                              properties:
                                answer1:
                                  type: string
                                  description: answer1
                                questionId:
                                  type: string
                                  description: questionId
                            description: answers
                          releaseDate:
                            type: string
                            description: releaseDate
                            title: ''
                            x-ms-visibility: internal
                          quizResult:
                            type: string
                            description: quizResult
                          emailReceiptConsent:
                            type: string
                            description: emailReceiptConsent
                            title: ''
                            x-ms-visibility: internal
                          submitLanguage:
                            type: string
                            description: submitLanguage
                            title: ''
                            x-ms-visibility: internal
                          msRewardsData:
                            type: string
                            description: msRewardsData
                            title: ''
                            x-ms-visibility: internal
                          FormsProData:
                            type: string
                            description: FormsProData
                            title: ''
                            x-ms-visibility: internal
                      description: value
            summary: Get form responses
            description: Get responses for a Microsoft Forms form
            operationId: GetFormResponses
            parameters:
              - name: Tenant Id
                in: path
                required: true
                type: string
              - name: Group Id
                in: path
                required: true
                type: string
              - name: Form Id
                in: path
                required: true
                type: string
      definitions: {}
      parameters: {}
      responses: {}
      securityDefinitions:
        oauth2_auth:
          type: oauth2
          flow: accessCode
          authorizationUrl: https://login.windows.net/common/oauth2/authorize
          tokenUrl: https://login.windows.net/common/oauth2/authorize
          scopes: {}
      security:
        - oauth2_auth: []
      tags: []

       

      • MKrings's avatar
        MKrings
        Copper Contributor

        johndpalm 

         

        Hello, I noticed the change regarding the URL as well. Thank you very much for your information.

        As far as I can see the form I want does not belong to a group and therefore I do not have a groupID to work with. Any suggestions on how to get the responses?

        (or any suggestions on how to get them as json in another way, as this is my main interest)

  • Thank you very much for your ask. This API  feature is in Microsoft Forms feature backlog

    • cardox007's avatar
      cardox007
      Copper Contributor
      I was able to install and use the library you created to get my forms but when I try to change use the Move-MSFormsToUser function to change the ownership from a group to a user it doesn't work

Resources