Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I have a question about multiple choice grid in google forms api

![]:(https://i.stack.imgur.com/5IOEd.png)
![]:(https://i.stack.imgur.com/feAyS.png)
How do I write json code?
I need an example of writing batchUpdate json in google form api.
thank you.

********

  const update = {
        requests: [
            {

                createItem: {
                    item: {
                        title: "TEST ",
                         title: "TEST RADIO",
                        questionGroupItem: {
                            grid: {
                                columns: {
                                    type: "RADIO",
                                    options: [
                                        { value: "A"},
                                        { value: "B"},
                                        { value: "C"},
                                        { value: "D"},
                                    ]
                                }
                            }
                        }
                    },
                    location: { index: 1 },
                },

            }

        ]
    };
const res = await forms.forms.batchUpdate({
        formId: createResponse.data.formId,
        requestBody: update,
    });
********

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

When I saw your request body, I thought that there are 2 modification points.

  • There are 2 title properties like title: "TEST ", and title: "TEST RADIO",.
  • In your request body, it is required to include rowQuestion of questions.

When these points are reflected in your script, it becomes as follows.

Modified request body:

const update = {
  "requests": [
    {
      "createItem": {
        "item": {
          "title": "TEST ",
          "questionGroupItem": {
            "grid": {
              "columns": {
                "type": "RADIO",
                "options": [
                  {
                    "value": "A"
                  },
                  {
                    "value": "B"
                  },
                  {
                    "value": "C"
                  },
                  {
                    "value": "D"
                  }
                ]
              }
            },
            "questions": [
              {
                "rowQuestion": {
                  "title": "smaple1"
                }
              },
              {
                "rowQuestion": {
                  "title": "sample2"
                }
              }
            ]
          }
        },
        "location": {
          "index": 1
        }
      }
    }
  ]
};
  • In this sample modified request body, 4 columns and 2 rows are created.

References:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading