Khalil Khalil
Khalil Khalil

Reputation: 117

Google Docs API create an empty document

I try now to create a document with Ggoogle Docs APIwith my content, but every time i create it, it will be embty, what should i do to fix the problem?

I use the same code from google example to do this. link to example

My Content example:

      {
        "title": "testitesti",
        "body": {
          "content": [
            {
              "endIndex": 1,
              "sectionBreak": {
                "sectionStyle": {
                  "columnSeparatorStyle": "NONE",
                  "contentDirection": "LEFT_TO_RIGHT",
                  "sectionType": "CONTINUOUS"
                }
              }
            },
            {
              "startIndex": 1,
              "endIndex": 6,
              "paragraph": {
                "elements": [
                  {
                    "startIndex": 1,
                    "endIndex": 6,
                    "textRun": {
                      "content": "test\n",
                      "textStyle": {}
                    }
                  }
                ],
                "paragraphStyle": {
                  "namedStyleType": "NORMAL_TEXT",
                  "direction": "LEFT_TO_RIGHT"
                }
              }
            }
          ]
        }
      }

Thanks

Upvotes: 1

Views: 329

Answers (1)

Iamblichus
Iamblichus

Reputation: 19309

documents.create will always create blank documents:

Creates a blank document using the title given in the request. Other fields in the request, including any provided content, are ignored.

If you want to add content to your document using document resource properties, use documents.batchUpdate.

Upvotes: 3

Related Questions