Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I rename a file to google drive rest api? Retrofit2

In the Google documentation about it is not written, I use retrofit 2. Help. Write what request should be sent and what parameters to transmit

interface:

 @PATCH("drive/v3/files/{fileId}")
    @Multipart
    Call<ResponseBody> renameFileGoogle(
            @Path("fileId")String fileId, 
            @Part MultipartBody.Part metaPart
    );

call metod:

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>()...
like image 862
Борисов Макс Avatar asked Feb 04 '23 13:02

Борисов Макс


1 Answers

It's there in the documentation https://developers.google.com/drive/v2/reference/files/patch

You need to send an HTTP PATCH request

PATCH https://www.googleapis.com/drive/v2/files/{fileId}

RequestBody:
{"title":"newTitle"}

For version 3 https://developers.google.com/drive/v3/reference/files/update

PATCH https://www.googleapis.com/drive/v3/files/{fileId}
RequestBody:
{"name":"newTitle"}
like image 194
Ahsan Iqbal Avatar answered Feb 07 '23 13:02

Ahsan Iqbal