-2

I used function to create metadata with template. but it throw exception com.box.sdk.BoxAPIException: The API returned an error code: 404

createMetadata(typename, scope, metadata);

1 Answers1

0

I did this and it seems to work.

BoxFile file = new BoxFile(api, "113280761775");
file.createMetadata(new Metadata().add("/test", "test"));

Metadata metadata = file.getMetadata();
System.out.println("printing out meta-data: " + metadata.get("/test"));
kendomen
  • 770
  • 6
  • 13
  • there no problem when we create metadata on file with "global" scope. In this case i had created Metadata Template with fields String, number or Date. But it throw BoxException with code 400 when assigning with field is number. Example: JsonObject jsonObject = new JsonObject(); jsonObject.add("/title", "title"); jsonObject.add("/author", "author"); jsonObject.add("/amount", 10); Metadata customerMetaData = new Metadata(jsonObject); uploadedFile.createMetadata("TemplateTest", customerMetaData); with TemplateTest has field 'amount' is Number – Thoảng Trần Apr 03 '17 at 14:33