Unable to select the items in multiselect through code

New post



  • Official comment
    Alex Novotny

    Hi Vijay, 

    Thank you for bringing this up! I have an answer for you. You will want to create a string array with the options you want. 

    Hope this helps! 


    Alex, Box Developer Advocate

    private static async Task CreateMetadataTemplateInstance(BoxClient adminClient)
    string[] selectedOptions = { "Author1", "Author2"};
    var metadataValues = new Dictionary<string, object>()
    { "author", selectedOptions }

    var metadata = await adminClient.MetadataManager.SetFileMetadataAsync(fileId: "123456", metadataValues, "enterprise", "multiselecttest");

    Console.WriteLine("Instance Added To File: ", metadata.ToString());

    Comment actions Permalink
  • Vijay Krishnan1

    I tried with the below also and getting the same error.

    List<string> lstSelectedAuthors = new List<string>() { "Author2", "Author3" };
    var metadataValues = new Dictionary<string, object>();

    metadataValues.Add("author", JsonConvert.SerializeObject(lstSelectedAuthors));

    var metadata = await _boxClient.MetadataManager.SetFileMetadataAsync(123456, metadataValues, "enterprise", "multiselecttest");

    Comment actions Permalink

Please sign in to leave a comment.