【发布时间】:2021-05-27 12:31:11
【问题描述】:
我们想在谷歌驱动器中创建一个谷歌文档。并想将数据添加到谷歌文档中。 我们现在正在驱动器中创建文件,但没有添加文档的正文(内容)。
以下是用于创建文件的代码
public static void createDocument(String folderId, String documentName) {
HttpRequest req = new HttpRequest();
req.setMethod('POST');
req.setEndpoint('https://www.googleapis.com/drive/v2/files');
req.setHeader('Authorization', 'Bearer '+accessToken);
req.setHeader('content-type', 'application/json');
req.setTimeout(60*1000);
String body = '{"title":"'+ documentName +'.txt","parents":[{"id":"'+ folderId +'"}],"body": {"content": "Text of document"}}';
req.setBody(body);
Http http = new Http();
HttpResponse res = http.send(req);
}
那么你能不能帮帮我们。
【问题讨论】:
标签: rest google-drive-api google-docs apex google-docs-api