我的程序正在創建文檔,每個文檔都有需要放入其中的文本。任何調用 的嘗試都會InsertTextRequest引發錯誤。List<Request> requests = new ArrayList<>();requests.add(new Request().setInsertText(new InsertTextRequest() .setText("Simple test.") .setLocation(new Location().setIndex(0))));BatchUpdateDocumentRequest body = new BatchUpdateDocumentRequest() .setRequests(requests);BatchUpdateDocumentResponse response = docService.documents() .batchUpdate(file.getId(), body).execute();Exception in thread "main" com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request{ "code" : 400, "errors" : [ { "domain" : "global", "message" : "Invalid requests[0].insertText: The insertion index must be inside the bounds of an existing paragraph. You can still create new paragraphs by inserting newlines.", "reason" : "badRequest" } ], "message" : "Invalid requests[0].insertText: The insertion index must be inside the bounds of an existing paragraph. You can still create new paragraphs by inserting newlines.", "status" : "INVALID_ARGUMENT"}即使嘗試在添加文本之前添加換行符也無法解決此問題。List<Request> requests = new ArrayList<>();requests.add(new Request().setInsertText(new InsertTextRequest() .setText("\n") .setLocation(new Location().setIndex(0))));requests.add(new Request().setInsertText(new InsertTextRequest() .setText("Simple test.") .setLocation(new Location().setIndex(0))));BatchUpdateDocumentRequest body = new BatchUpdateDocumentRequest() .setRequests(requests);BatchUpdateDocumentResponse response = docService.documents() .batchUpdate(file.getId(), body).execute();這也會調用相同的錯誤。如何正確添加文本?
- 1 回答
- 0 關注
- 126 瀏覽
添加回答
舉報
0/150
提交
取消