Assign Metadata Template created in admin console to files - Java SDK

Answered
New post

Comments

2 comments

  • Murtza

     Can you please share the error message that the API is returning along with the error code? 

    0
    Comment actions Permalink
  • GiacomoZecchin

    I have resolved, thanks you the same 😃

     

    1) Create a MetadataTemplate from a copy based on a pre-existing schema (defined from admin console):

    FileReader reader = new FileReader("path/to/schema.json");

    JSONParser jsonParser = new JSONParser();
    JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);

    // create MetadataTemplate based on JSON stringified
    MetadataTemplate imgTemplate = new MetadataTemplate(jsonObject.toJSONString());

     

    2) Create a NEW Metadata with the correct couple key:values (attention on types of key):

    Metadata metadata = new Metadata().add("/key1", "valu1").add("/key2", "value2");

     

    3) Assign template to file you want to with custom metadata

    //file.createMetadata(imgTemplate.getTemplateKey(), imgTemplate.getScope(), metadata); 

     

    0
    Comment actions Permalink

Please sign in to leave a comment.