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
}
}
]
}
I believe your goal is as follows.
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.
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
When the above request body is used, the following result is obtained.