question

EdMaybert-5240 avatar image
0 Votes"
EdMaybert-5240 asked romungi-MSFT commented

SpellCheck Connectivity Issue

I have been working with the support team for the following issue.

In my C# code ( from the tutorial ) I get the following errors:

InnerException = {"The underlying connection was closed: An unexpected error occurred on a send."}
InnerException = {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."}

When using the following endpoints:
https://api.bing.microsoft.com/v7.0/SpellCheck/
https://api.bing.microsoft.com/v7.0/search

When we switched to this endpoint:
https://api.cognitive.microsoft.com/bing/v7.0/news/search

I received a response, but the response object was:
{StatusCode: 401, ReasonPhrase: 'PermissionDenied', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:{ Date: Fri, 15 Jan 2021 00:49:11 GMT Content-Length: 224}}

We tried both keys and they seemed to check out as valid.

Any help would be appreciated.

azure-bing-spellcheck
· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@EdMaybert-5240 The first set of bing API's you mentioned are correct and should work with the right key. Could you please try to use these keys with the endpoint through postman or a simple curl command? I think the issue could be in the SDK that is being used with your code as the bing resources migrated from cognitive services to bing in October there were issues reported with the SDK's for python.

Since you are receiving a permission denied error with the older endpoint it seems to be behaving as expected after the migration.

0 Votes 0 ·

Thanks for getting back to me.
I ran the first and second endponts through Postman and, as suggested, they worked.
So currently, I'm using the c# example from the Tutorial page.
Is that no longer valid?
Is there something I should be using instead to properly call from a c#/.NET app?

Thanks,
~ed

0 Votes 0 ·

@EdMaybert-5240 Are you using the SDK or the REST API sample? I have tried the sample from the documentation which is referenced in this github page. This seems to work without any issues, the only change I did was to update the endpoint and key variable directly instead of using an environment variable.

 static string subscriptionKey = "<your_key>";
 static string endpoint = "https://api.bing.microsoft.com/v7.0/search";


56939-image.png


0 Votes 0 ·
image.png (57.4 KiB)
Show more comments

1 Answer

romungi-MSFT avatar image
0 Votes"
romungi-MSFT answered romungi-MSFT commented

@EdMaybert-5240 The following should work.

 static string subscriptionKey = "<key>";
 static string endpoint = "https://api.bing.microsoft.com/v7.0";
 static string path = "/spellcheck?"


64021-image.png



image.png (65.0 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@EdMaybert-5240 Did you get a chance to check if the above changes worked?

0 Votes 0 ·