Bing SpellCheck

Eduardo Gomez 3,416 Reputation points
2022-08-31T20:52:23.247+00:00

I am trying to correct this text, using Bing Spell API

I am using postman, just to see what I get in return, but I do not know where to put the text

236706-image.png

https://api.bing.microsoft.com/v7.0/spellcheck?proof&en-US  

This is the text I want to correct

I believe we have some power over who we love.It isn't just something that happens to a person.And yes, you can stand there and tell me that the poets would disagree, but I am not a poet.I am just a woman and as a woman I have no way to make money.Not enough to earn a living and support my family.Even if I had my own money, which I don't, it would belong to my husband the minute we were married.If we have children, they belong to him, not me. They are his property.So don't sit there and tell me that marriage isn't an economic proposition, because it is. It may not be for you.But it most certainly is for me.That will be Fred now.How do I look?Do I look alright?

I did it in c#, and I got 401

static string Url = "https://api.bing.microsoft.com/v7.0/spellcheck?proof&en-US";  
    readonly HttpClient Client = new();  
  
    public BingService()  
    {  
        Client = new HttpClient();  
        Client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", Key);  
    }  
  
    public async Task<SpellCheckModel?> BingProcessString(string str)  
    {  
        var text = $"&text={str}";  
        var res = await Client.GetAsync($"{Url}{text}");  
        if (res.IsSuccessStatusCode)  
        {  
            var model = await res.Content.ReadFromJsonAsync<SpellCheckModel>();  
            return model;  
        }  
  
        return null;  
    }  

And finally I call it in my VM

   public MainWindowViewModel()  
    {  
        CopyCommand = new Command(CopyAction);  
        //AzureCommand = new Command(AzureActionAsync);  
        Words = new List<char>();  
        str = "I believe we have some power over who we love.It isn't just something that happens to a person.And yes, you can stand there and tell me that the poets would disagree, but I am not a poet.I am just a woman and as a woman I have no way to make money.Not enough to earn a living and support my family.Even if I had my own money, which I don't, it would belong to my husband the minute we were married.If we have children, they belong to him, not me. They are his property.So don't sit there and tell me that marriage isn't an economic proposition, because it is. It may not be for you.But it most certainly is for me.That will be Fred now.How do I look?Do I look alright?";  
        bs.BingProcessString(str);  
    }  
  

![236686-image.png][2] [2]: /api/attachments/236686-image.png?platform=QnA

Bing Spell Check
Bing Spell Check
A Bing service that detects and corrects spelling mistakes in your app.
30 questions
0 comments No comments
{count} votes

Accepted answer
  1. romungi-MSFT 42,206 Reputation points Microsoft Employee
    2022-09-01T11:51:44.553+00:00

    @Eduardo Gomez For the first scenario with the postman tool you need to add a query parameter for text and pass in the text as value. I could see that the other two query parameters are passed without the key for which the API defaults to mode and market parameters but since the text key is missing the message from the API is to include the text parameter. Please see the request below that I used with same text and the response.

    236919-image.png

    For the second scenario, I think the reason for failure is the same where you are not passing the key for the parameters, and you would also need to debug the request passed to check if you are passing the key correctly with the header since 401 error could indicate the key is not passed correctly to the API.

    If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful