Andrew Rose
Andrew Rose

Reputation: 11

Why does azure search .net fail with UTF-8 error when calling Indexes.Exists

I have tried to use the Azure Search .net api but I cannot get past a UTF-8 encoding error when I try to either check if an index exists or create an index.

To keep things simple I tried downloading

https://github.com/Azure-Samples/search-dotnet-getting-started

Built the DotNetHowTo.sln with an updated appsettings.json but running the program results in the same error I get in my application:

The call to:

if (serviceClient.Indexes.Exists("hotels"))

Results in

System.InvalidOperationException: 'The character set provided in ContentType is invalid. Cannot read content as string using an invalid character set.'

Inner Exception ArgumentException: '"UTF-8"' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.

Upvotes: 0

Views: 261

Answers (1)

Andrew Rose
Andrew Rose

Reputation: 11

This turned out to be a Sophos Web Appliance related issue. Sophos has facility to validate certificates and you have to add *.search.windows.net so it can trust the necessary certificates.

Redacted Sophos Configuration Image

Upvotes: 1

Related Questions