MetadataTemplate.Field titleField = new MetadataTemplate.Field();
titleField.setType("string");
titleField.setKey("title");
titleField.setDisplayName(“Title");
MetadataTemplate.Field authorField = new MetadataTemplate.Field();
authorField.setType("string");
authorField.setKey("author");
authorField.setDisplayName("Author");
MetadataTemplate.Field subjectField = new MetadataTemplate.Field();
subjectField.setType("string");
subjectField.setKey("subject");
subjectField.setDisplayName("Subject");
MetadataTemplate.Field amountField = new MetadataTemplate.Field();
amountField.setType("float");
amountField.setKey("amount");
amountField.setDisplayName("Amount");
MetadataTemplate.Field publishDateField = new MetadataTemplate.Field();
publishDateField.setType("date");
publishDateField.setKey("publishDate");
publishDateField.setDisplayName("PublishDate");
MetadataTemplate.Field categoryField = new MetadataTemplate.Field();
categoryField.setType("enum");
categoryField.setKey("category");
categoryField.setDisplayName("Category");
List options = new ArrayList();
options.add("novel");
options.add("comics");
options.add("science");
options.add("education");
categoryField.setOptions(options);
List fields = new ArrayList();
fields.add(titleField);
fields.add(authorField);
fields.add(subjectField);
fields.add(amountField);
fields.add(publishDateField);
fields.add(categoryField);
try {
MetadataTemplate template = MetadataTemplate.createMetadataTemplate(api, "enterprise",
"TemplateTest", "Template Test", false, fields);
} catch (BoxAPIException apiEx) {
//Delete MetadataTemplate is yet to be supported. Due to that template might be existing already.
//This expects the conflict error.
Assert.assertEquals(apiEx.getResponseCode(), 409);
Assert.assertTrue(apiEx.getResponse().contains("Template key already exists in this scope"));
}
MetadataTemplate storedTemplate = MetadataTemplate.getMetadataTemplate(api, "documentFlow03");
Assert.assertNotNull(storedTemplate);
final 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);
It throws BoxException with responseCode 400 when creating Metadata with type Number and Date. Pls tell me how to resolve this problem if you have example about it, pls share with me.
Question
Create metadata on file with template
I’m developing a app integration with Box. I’ve use Box Java SDK. But I have a problem when use Template.
I create a Template “TemplateTest” with fields “String | enum | Date”.
Sign up
Already have an account? Login
Community access is available only with a Box Account.
Sign in with your Box AccountSign in to the Box Community
No account yet? Create an account
Community access is available only with a Box Account.
Sign in with your Box AccountEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.
