Add values to structured metadata fields using API/SDK

Options
hwajain
hwajain Member Posts: 4
edited May 2023 in Developer APIs

Able to set values for multiselect dropdowns and strings, but run into errors when setting value for single select dropdowns. The errors states the value being assigned is not valid, looking at the fields in Cloudinary, the value is valid, tried external_id and value, same error on both.

Code

List<string> values = new List<string>() { "" };

            StringDictionary keyValuePairs = new StringDictionary();

            keyValuePairs.Add("marked_as_medical_image", new List<string>() { "no" });

            var metadataParams = new MetadataUpdateParams()

            {

              PublicIds = new List<string>() { publicID },

              Metadata = keyValuePairs

            };

            MetadataUpdateResult MUR = cloudinary.UpdateMetadata(metadataParams);

Answers

  • Vdeub
    Vdeub Member, Cloudinary Staff Posts: 55
    edited May 2023
    Options

    Hi there,

    Based on the sdkerror screenshot and our logs, it seems you are passing an array (`["no"]`) while you should just pass a value (`"no"`) since it is a single-selection list SMDs.

    Hope that helps.

    Best,

    Loic