C# browse method not working

Hi There,
I want to query all of my index objects ID, but I’m getting the error: "Unable to evaluate expression " Here’s the function I’m trying to implement:

public List GetAlgoliaProducts()
{
List lstProducts = new List();
try
{
SearchClient client = new SearchClient(“LHLPD5B9OK”, “d47846c40b707e6124b3dfedd9d04090”);
SearchIndex index = client.InitIndex(“Medisca_Products”);
/IndexSettings settings = new IndexSettings { AttributesToRetrieve = new List {"" }};
index.SetSettings(settings);*/
IndexIterator indexIterator = index.Browse(new BrowseIndexQuery { AttributesToRetrieve = new List { “objectID” }});
foreach(var hit in indexIterator)
{
lstProducts.Add(hit.ToString());
}
}
catch
{
lstProducts = new List();
}
return lstProducts;
}

I’m not sure why you’re getting the “unable to evaluate expression” error. Generally what you are doing looks correct and I was able to get your code to run after injecting some type information:

  try
  {
      // Start the API client
      SearchClient client = new SearchClient(_appId, _apiKey);

      // Create an index (or connect to it, if an index with the name `ALGOLIA_INDEX_NAME` already exists)
      SearchIndex index = client.InitIndex(_indexName);

      List<string> lstProducts = new List<string>();

      // Browse the index for all objectIDs
      IndexIterator<Contact> indexIterator = index.Browse<Contact>(new BrowseIndexQuery { AttributesToRetrieve = new List<string> { "objectID" }});

      foreach (var hit in indexIterator)
      {
          Console.WriteLine(hit.ToString());
          lstProducts.Add(hit.ToString());
      }

  }
  catch
  {
      Console.WriteLine("Something went wrong");
  }