Skip to main content

.Net API Search attributes and WithField() does not work

Comments

2 comments

  • Shirly Manor

    Hi Joseph,

    The search API is meant to find public_ids by searching a specific string.

    If I'll search for:

    SearchResult result = cloudinary.Search().Expression("cat")
      .MaxResults(50)
      .Execute();

    It will search the string "cat" in the images name (public_id). If I want it to escalate the search for also search on tags I'll need to add :

    SearchResult result = cloudinary.Search().Expression("cat")
      .WithField("tags")
      .MaxResults(50)
      .Execute();

    If you want to get information on your assets. You might want to use our Admin API.

    For example, you can try getting the information about your sample image:

    cloudinary.GetResource("sample");

    In response, you will get all the information about this asset (e.g., tags,color,context..).

     

    Hope that helps,

    0
  • Joseph Huddleston

    Your example would search ALL fields for resources containing "cat".

    I want to return all resources in the folder "cats\kittens". Therefore, I am using the expression "folder=cats\kittens". I just want to see the tags for other purposes.

    The documentation regarding with_field, or .Net’s WithField(), suggests using it provides "the name of an additional asset attribute to *include for each asset* in the response." (* are my emphasis from https://cloudinary.com/documentation/search_api#parameters)

    That explanation is how it works when I use the endpoint method in Postman. See my example below

    URL: https://<API_KEY>:<API_SECRET>@api.cloudinary.com/v1_1/<cloud_name>/resources/search

    BODY: {"expression": "folder=cats\kittens","with_field": ["tags"]}

    In that example, I see get resources AND the tags field is returned for each one. It is not returned if I remove "with_field".

    The .net api does not behave this way. I don’t want to bombard you nor increase my request time with a bunch of requests to get the tag if I don’t have to.

    0

Post is closed for comments.