Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive api v3 (java): Deleting a resource property does not work

I'm using the Google Drive API for Java (v3-rev111-1.23). I'm trying to remove a property from a resource. I followed this documentation:

https://developers.google.com/drive/v3/reference/files/update https://developers.google.com/drive/v3/web/migration#methods

This is the code I wrote:

Drive service = getDriveService();
File file = new File();
Map<String,String> properties = new HashMap<>();
properties.put("propA", null);
file.setProperties(properties);

file = service.files().update(fileId, file).execute();

The problem is that the property is never cleared. Remains with the previous value.

If I write the generated json with:

System.out.println(service.files().update(fileId, file).getJsonContent());

I get:

{properties={propA=null}}

Using the same code to add a new property like:

properties.put("test", "yes");

I get:

{properties={test=yes}}

and it works properly.

Has someone faced and solved this problem?

I read this post Google Drive Java API V3 delete custom property from 2016, but no solution was given.


More details:

Using the try-its of the web (https://developers.google.com/drive/v3/reference/files/update) I could create properties, modify them and even delete them.

Thanks.

like image 284
Victor Podberezski Avatar asked Nov 01 '25 19:11

Victor Podberezski


1 Answers

Here's what I can share that might help you, using the Try-its:

I created a file using Files.create and created a custom property

appProperties{
  "supersaiyan": "yes"
}

Then I deleted it using Files.update:

appProperties{
  "supersaiyan": null
}

When I tried to fetch the appProperties, I got {} which means successfully deleted.

like image 93
ReyAnthonyRenacia Avatar answered Nov 04 '25 10:11

ReyAnthonyRenacia