Gravatar for

Question by prabhatsingh2011, Oct 2, 2016 8:53 AM

Read AdminServiceUri from coveo configuration in code

Please help me getting the adminserviceuri value from coveo config ? I have added a service reference for adminserviceuri. But it's url is going to change across the server. So need to make sure my code work in all environments.

2 Replies
Gravatar for

Answer by prabhatsingh2011, Oct 2, 2016 9:14 AM

I finally got it.

Coveo.Framework.Configuration.AdminServiceConfiguration adminserviceConfig = new Coveo.Framework.Configuration.AdminServiceConfiguration();
var serviceUri= adminserviceConfig.AdminServiceUri;
Gravatar for

Answer by Jean-François L'Heureux, Oct 3, 2016 10:28 AM


Your method works fine to read the Admin service URI from the Coveo default index configuration. However, the configuration can be different from one Sitecore index to another. The recommended way is to use an ISearchIndex object first:

ISearchIndex index = ContentSearchManager.GetIndex("Coveo_web_index"); // Change the name of the index depending of your Sitecore context
CoveoIndexConfiguration indexConfiguration = ((CoveoIndexConfiguration) index.Configuration);
var adminServiceUri = indexConfiguration.AdminServiceConfiguration.AdminServiceUri;
Ask a question