0

I'm trying to use the Google Slides API to create nested bullet points within a paragraph. Currently, I'm able to create a paragraph with bullet points, but I'm struggling to create sub-bullet points (nested bullet points) under existing bullet points.

Here's the current request body I'm using:

{
  "requests": [
    {
      "createParagraphBullets": {
        "objectId": "i0",
        "textRange": {
          "type": "ALL"
        },
        "bulletPreset": "BULLET_DISC_CIRCLE_SQUARE"
      }
    },
    {
      "createParagraphBullets": {
        "objectId": "i0",
        "textRange": {
          "type": "ALL"
        },
        "bulletPreset": "BULLET_DISC_CIRCLE_SQUARE"
      }
    }
  ]
}

How can I modify the above code to create sub bullet points (nested bullet points) under the bullet points created by the first request using the Google Slides API? I tried nestingLevel suggested by ChatGPT but no luck!

ChatGPT result:

{
    "requests": [
      {
        "createParagraphBullets": {
          "objectId": "i0",
          "textRange": {
            "type": "ALL"
          },
          "bulletPreset": "BULLET_DISC_CIRCLE_SQUARE"
        }
      },
      {
        "createParagraphBullets": {
          "objectId": "i0",
          "textRange": {
            "type": "ALL"
          },
          "bulletPreset": "BULLET_DISC_CIRCLE_SQUARE",
          "nestingLevel": 1
        }
      }
    ]
  }

sample image of what I want to achieve

2
  • I refined my query, hope its clear now! Commented Mar 7, 2024 at 13:53
  • Actually I couldn't find any way to create nested/sub bullet points in google slides API docs, I am searching for solution that worked for anyone. Currently I am mimicking sub bullet points in this way but its not the proper way: ``` { "requests": [ { "insertText": { "objectId": "i0", "text": "bullet point 1\n\t•\tNested bullet point", "insertionIndex": 0 } } ] } ``` Commented Mar 7, 2024 at 14:01

1 Answer 1

0

I believe your goal is as follows.

  • You want to create a nest list in a text box on Google Slides.
  • You want to achieve this using "Method: presentations.batchUpdate" of Google Slides API.

In this case, how about the following request body? Unfortunately, from your question, I couldn't understand your input situation. So, in this answer, the request body also includes creating a text box and the texts.

Sample request body:

To create the nest list, the tab \t is used in the inserting text. And also, at createParagraphBullets, "type": "ALL" is used. By this, the nest structure is automatically created using \t.

{
  "requests": [
    {
      "createShape": {
        "shapeType": "RECTANGLE",
        "elementProperties": {
          "size": {
            "height": {
              "unit": "PT",
              "magnitude": 200
            },
            "width": {
              "unit": "PT",
              "magnitude": 200
            }
          },
          "pageObjectId": "###"  // <--- Please set your page object ID.
        },
        "objectId": "abc123456"
      }
    },
    {
      "insertText": {
        "text": "sample1\n\tsample2\n\t\tsample3",
        "objectId": "abc123456"
      }
    },
    {
      "createParagraphBullets": {
        "bulletPreset": "BULLET_DISC_CIRCLE_SQUARE",
        "objectId": "abc123456",
        "textRange": {
          "type": "ALL"
        }
      }
    }
  ]
}

The sample curl command using this request body is as follows.

curl --request POST \
  'https://slides.googleapis.com/v1/presentations/{googleSlideId}:batchUpdate' \
  --header 'Authorization: Bearer [YOUR_ACCESS_TOKEN]' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data '{"requests":[{"createShape":{"shapeType":"RECTANGLE","elementProperties":{"size":{"height":{"unit":"PT","magnitude":200},"width":{"unit":"PT","magnitude":200}},"pageObjectId":"###"},"objectId":"abc123456"}},{"insertText":{"text":"sample1\n\tsample2\n\t\tsample3","objectId":"abc123456"}},{"createParagraphBullets":{"bulletPreset":"BULLET_DISC_CIRCLE_SQUARE","objectId":"abc123456","textRange":{"type":"ALL"}}}]}' \
  --compressed

Testing:

When the above request body is used, the following result is obtained.

enter image description here

References:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.