谷歌文档里没有写关于它的,我用的是retrofit 2。求助。写出应该发什么请求,传什么参数
接口(interface):
@PATCH("drive/v3/files/{fileId}")
@Multipart
Call<ResponseBody> renameFileGoogle(
@Path("fileId")String fileId,
@Part MultipartBody.Part metaPart
);
调用方法:
public void renameMetod(String id, String title) {
String content = "{\"name\": \"" + title + "\"}";
MediaType contentType = MediaType.parse("application/json; charset=UTF-8");
MultipartBody.Part metaPart = MultipartBody.Part.create(RequestBody.create(contentType, content));
Call<ResponseBody> renameRequest = server.renameFileGoogle(id, metaPart);
renameRequest.enqueue(new Callback<ResponseBody>()...
最佳答案
它在文档中 https://developers.google.com/drive/v2/reference/files/patch
您需要发送 HTTP PATCH 请求
PATCH https://www.googleapis.com/drive/v2/files/{fileId}
RequestBody:
{"title":"newTitle"}
对于版本 3 https://developers.google.com/drive/v3/reference/files/update
PATCH https://www.googleapis.com/drive/v3/files/{fileId}
RequestBody:
{"name":"newTitle"}
关于android - 如何将文件重命名为 google drive rest api?改造2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43705453/