Skip to main content

How to retrieve metadata



  • Alain Nicli

    I answer myself. You should pass context=true to get the metadata info

    ObjectUtils.asMap("context", "true")
  • Maor Gariv


    Feel free to reach out again with further questions or requests.

  • Viral Munshi

    Hi Maor,


    I need to do the same but i need to use javascript API. I have a tag on metadata but when i get the resource by tag using URL, I dont get metadata back.


    Can you help?




  • Maor Gariv

    Hi Viral,


    Please note that we don't recommend on using the Admin API (per your shared URL) on the client-side.

    For client-side resource listing you can use our Json listing with a shared tag -

    This method supports returning the context and not the metadata.


    For querying the metadata, you can use our Search API (tier2) -


    Hope it helps, let me know if you have any further questions.


    Kind regards,


  • Peter Ekene Eze

    Hello Maor

    I have an android project.

    I am using a signed upload to pass an image caption to my upload option() method.

    When the the image is uploaded, i do not get the context in the response resource, however i gat the tags.

    .option("folder", "images/")
    .option("tags", "food")
    .option("context", "Pizza")
    .callback(new UploadCallback(){

    Please clarify, what am i doing wrong

  • Daniel Mendoza

    @Peter Ekene Eze

    In order to pass context, it needs to be done using the following:

    A map (using the SDKs) or pipe-separated list (for direct API calls) of the key-value pairs of general textual context metadata to attach to an uploaded resource. The context values of uploaded files are available for fetching using the Admin API. For example: alt=My image❘caption=Profile image (the = and  characters can be supported as values when escaped with a prepended backslash (\)). Note that key values are limited to 1024 characters. These details can be found here: under Optional parameters.

    An example using map in Java:

    Map<String,String> map= new HashMap<>();
    map.put("alt", "pizza");

    And then pass that map into the context:

    .option("folder", "images/")
    .option("tags", "food")
    . . .

    Then the upload will include the result like so:

    { . . . context={custom={alt=pizza}} . . . }
  • Peter Ekene Eze

    Hi Daniel,


    Thanks for the reply.


    I implemented the Map as you instructed in the last message but i got a new error

     java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String

    How do i fix it please

  • Peter Ekene Eze

    Hi Daniel,

    I have an update, i've been able to fix the error (java.lang.ClassCastException: java.util.HashMap cannot be cast to java.lang.String) by storing the map in a String variable before passing it into the context.

    Map<String,Object> map = new HashMap<>();
    map.put("alt", "pizza");
    final String context = map.toString();

    Then i passed it in like:

    .option("folder", "images/")
    .option("tags", image_price)
    .option("context", context)

    However i want to retrieve the value "pizza" into a String variable, but the response is not in the standard json object format :

    { . . . "context" : {"custom" = {"alt" = pizza}} . . . }

    The response i got was:

    { . . . context = {custom = {alt = pizza}} . . . }

    How do i read the "alt" value into a String variable.

  • Yakir Perlin

    Hi Peter, 


    Please use this code in order to read the context values:


    Map<String, HashMap<String,String>> contextResponseData  = (HashMap)resultData.get("context");
    String value = String.valueOf(contextResponseData.get("custom").get("alt")));  //pizza

    Please let me know if it works for you.





  • Peter Ekene Eze

    Hello Yakir,


    Thanks for the feedback


    I implemented it as you advised and i was able to read the values, it works fine now




Post is closed for comments.