Skip to main content
Question

How to associate Metadata to Document / folder using JDK API

  • May 21, 2025
  • 3 replies
  • 9 views

Forum|alt.badge.img

Hello All,

 

I want to associate the metadata template created by admin to my documents using java sdk API.

 

How can i do the same ? can someone provide me sample of API or reference 

3 replies

Forum|alt.badge.img

Java docs API says to use followng method, I am trying to use the same getting 404 error. 

 

Anyone tried this ?

 

public Metadata createMetadata(String typeName, Metadata metadata)


Forum|alt.badge.img

I tried something simple and it seems to work.

 

public static void main(String[] args) {
        BoxAPIConnection api = new BoxAPIConnection(DEVELOPER_TOKEN);

        BoxFile file = new BoxFile(api, "removed for privacy33");
        file.createMetadata(new Metadata().add("/foo", "bar"));

        Metadata metadata = file.getMetadata();
        System.out.println("printing out meta-data: " + metadata.get("/foo"));
}

Here's my output:


printing out meta-data: bar

Process finished with exit code 0


Forum|alt.badge.img

Hi Kendomen,

  I created Metadata the same way you described, but while searching  for the key, I'm not getting any results. 

 

Thanks,

Veemini.