API Request Methods
The following are the request methods supported by Docs APIs:
Create: It Creates a new, blank Google Docs document.
Get: It returns the complete instance of the document specified. You can resolve the returned JSON to extract the document content, formatting it and some other features.
Batch update: It Submits a list of editing requests to apply to the document and returns a list of results.
These methods can be invoked using a client library method or directly as an HTTP request, which returns the appropriate response for the invocation style.
The batch update method usually works by taking one or more Request objects, each one specifies a single kind of request to perform. There are many different kinds of requests. Here is the breakdown of the types of requests which are grouped into different categories.
Working with text | replaceAllText insertText |
Working with styles | updateTextStyle updateParagraphStyle createParagraphBullets deleteParagraphBullets |
Working with ranges | createNamedRange deleteNamedRange deleteContentRange |
Working with images | insertInlineImage |
The below shown is the popular pattern followed for making batch requests: Here he API validates each request within a batchUpdate call before applying them and checks if any request is invalid, then the entire batch fails and the document is left without applying any changes on it.
requests = []
requests.append(some request)
requests.append(another one)
requests.append(and another one)
.
.
.
body = ... & requests & ...
...batchUpdate(body)