Java SDK Update metadata attribute on a file
回答済みHi,
I've troubles updating a metadata attribute on a file.
I followed the instructions on the github site and on the documentation site.
BoxFile file = new BoxFile(api, "id");
file.updateMetadata(new Metadata().add("/foo", "bar"));
In my case:
BoxFile boxBestand = new BoxFile(api, bestandsId);
boxBestand.updateMetadata(new Metadata().add("/"+veld, waarde));
Tried:
BoxFile boxBestand = new BoxFile(api, bestandsId);
boxBestand.updateMetadata(boxBestand.createMetadata(template, "enterprise", new Metadata().add("/"+veld, waarde));
And tried this method:
BoxFile boxBestand = new BoxFile(api, bestandsId);
Metadata metadata = new Metadata();
metadata = boxBestand.getMetadata(template, "enterprise");
metadata = metadata.replace("/"+veld, waarde);
boxBestand.updateMetadata(boxBestand.createMetadata(template, "enterprise", metadata));
All I get is 400 errors.
The API returned an error code [400 | bu1qqzggyxcgu1z4.034474d9889552d8bf4cf8604601c282d] schema_validation_failed - object instance has properties which are not allowed by the schema: ["retentiebeleid"]
Regards,
Marcel
-
Is "foo" already a metadata attribute on the file or is something you are adding. If you are adding it, the Github code should work. If you are updating the attribute, then you have to do file.updateMetadata(file.getMetadata().replace("/foo", "bar")) as shown here.
サインインしてコメントを残してください。
コメント
2件のコメント