Method: documents.create
使用要求中提供的標題建立空白文件。要求中的其他欄位 (包括任何提供的內容) 都會遭到忽略。
傳回已建立的文件。
HTTP 要求
POST https://docs.googleapis.com/v1/documents
這個網址使用 gRPC 轉碼語法。
要求主體
要求主體的資料會採用以下結構:
JSON 表示法 |
{
"documentId": string,
"title": string,
"tabs": [
{
object (Tab )
}
],
"revisionId": string,
"suggestionsViewMode": enum (SuggestionsViewMode ),
"body": {
object (Body )
},
"headers": {
string: {
object (Header )
},
...
},
"footers": {
string: {
object (Footer )
},
...
},
"footnotes": {
string: {
object (Footnote )
},
...
},
"documentStyle": {
object (DocumentStyle )
},
"suggestedDocumentStyleChanges": {
string: {
object (SuggestedDocumentStyle )
},
...
},
"namedStyles": {
object (NamedStyles )
},
"suggestedNamedStylesChanges": {
string: {
object (SuggestedNamedStyles )
},
...
},
"lists": {
string: {
object (List )
},
...
},
"namedRanges": {
string: {
object (NamedRanges )
},
...
},
"inlineObjects": {
string: {
object (InlineObject )
},
...
},
"positionedObjects": {
string: {
object (PositionedObject )
},
...
}
} |
欄位 |
documentId |
string
僅供輸出。文件 ID。
|
title |
string
文件標題。
|
tabs[] |
object (Tab )
文件中的分頁。 分頁可以包含子分頁,也就是在另一個分頁中巢狀的分頁。子分頁會以 Tab.childTabs 欄位表示。
|
revisionId |
string
僅供輸出。文件的修訂版本 ID。可在更新要求中使用,用於指定要套用更新的文件修訂版本,以及如果文件在該修訂版本之後經過編輯,要求應如何運作。只有在使用者具備文件的編輯權限時,才會填入這項資料。 修訂版本 ID 不是連續編號,而是不透明字串。修訂版本 ID 的格式可能會隨時間變更。系統傳回的修訂版本 ID 只保證在傳回後的 24 小時內有效,且無法跨使用者共用。如果兩次呼叫之間的修訂 ID 沒有變更,表示文件並未變更。相反地,如果 ID 有所變更 (針對相同的文件和使用者),通常表示文件已更新。不過,ID 變更也可能是因為 ID 格式變更等內部因素造成。
|
suggestionsViewMode |
enum (SuggestionsViewMode )
僅供輸出。套用至文件的建議檢視模式。 注意:編輯文件時,變更必須以含有 SUGGESTIONS_INLINE 的文件為依據。
|
body |
object (Body )
僅供輸出。文件的主要內容。 舊版欄位:請改用 Document.tabs.documentTab.body ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
headers |
map (key: string, value: object (Header ))
僅供輸出。文件中的標頭,以標頭 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.headers ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
footers |
map (key: string, value: object (Footer ))
僅供輸出。文件中的頁尾,以頁尾 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.footers ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
footnotes |
map (key: string, value: object (Footnote ))
僅供輸出。文件中的註腳,以註腳 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.footnotes ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
documentStyle |
object (DocumentStyle )
僅供輸出。文件樣式。 舊版欄位:請改用 Document.tabs.documentTab.documentStyle ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
suggestedDocumentStyleChanges |
map (key: string, value: object (SuggestedDocumentStyle ))
僅供輸出。建議的文件樣式變更,以建議 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.suggestedDocumentStyleChanges ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
namedStyles |
object (NamedStyles )
僅供輸出。文件的命名樣式。 舊版欄位:請改用 Document.tabs.documentTab.namedStyles ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
suggestedNamedStylesChanges |
map (key: string, value: object (SuggestedNamedStyles ))
僅供輸出。建議變更文件的命名樣式,並以建議 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.suggestedNamedStylesChanges ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
lists |
map (key: string, value: object (List ))
僅供輸出。文件中的清單,以清單 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.lists ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
namedRanges |
map (key: string, value: object (NamedRanges ))
僅供輸出。文件中的已命名範圍,以名稱做為索引。 舊版欄位:請改用 Document.tabs.documentTab.namedRanges ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
inlineObjects |
map (key: string, value: object (InlineObject ))
僅供輸出。文件中的內嵌物件,以物件 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.inlineObjects ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
positionedObjects |
map (key: string, value: object (PositionedObject ))
僅供輸出。文件中已定位的物件,以物件 ID 做為索引。 舊版欄位:請改用 Document.tabs.documentTab.positionedObjects ,當 includeTabsContent 參數設為 true 時,這會顯示所有分頁的實際文件內容。如果為 false 或未設定,則此欄位會包含文件中第一個分頁的相關資訊。
|
回應主體
如果成功,回應主體會包含新建立的 Document
例項。
授權範圍
需要下列其中一種 OAuth 範圍:
https://www.googleapis.com/auth/documents
https://www.googleapis.com/auth/drive
https://www.googleapis.com/auth/drive.file
詳情請參閱授權指南。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-11-30 (世界標準時間)。
[null,null,["上次更新時間:2024-11-30 (世界標準時間)。"],[[["Creates a new Google Docs document with the specified title, leaving all other content blank."],["Uses a POST request to `https://docs.googleapis.com/v1/documents` with the document title in the request body."],["Returns the newly created document object in the response."],["Requires authorization with specific Google Docs or Drive scopes."]]],[]]