Handling the spell check response

When you send a request to Spell Check API, it returns a SpellCheck object in the response body. The flaggedTokens list contains a FlaggedToken object for each word that Bing flagged for spelling and grammar issues. If the API didn't find an error, or the specified market is not supported, the list is empty.

{
  "_type" : "SpellCheck",  
  "flaggedTokens" : [ ... ]
}

The FlaggedToken object identifies the word that caused the issue, the location in the text string where it was found, and a list of suggestions for fixing the issue.

    {
      "offset": 5,
      "token": "its",
      "type": "UnknownToken",
      "suggestions": [
        {
          "suggestion": "it's",
          "score": 0.8048868675051712
        }
      ]
    },

In the text string, replace word in token with the word in suggestion. Use the zero-based offset in offset to find the token in the text string.

If the type field is RepeatedToken, you also replace token with suggestion, but you may need to remove the trailing space.

    {
      "offset": 19,
      "token": "turn",
      "type": "RepeatedToken",
      "suggestions": [
        {
          "suggestion": "",
          "score": 0
        }
      ]
    },

If an error occurs, the response body contains an ErrorResponse object. Bing returns an error response for all 400 level HTTP status codes. Read more.

{
  "_type": "ErrorResponse", 
  "errors": [
    {
      "code": "InvalidAuthorization", 
      "subCode": "AuthorizationMissing", 
      "message": "Authorization is required.", 
      "moreDetails": "Subscription key is not recognized."
    }
  ]
}

Based on the text string, when its your turn turn, john, come runing, the following table shows a side-by-side comparison of the spelling and grammar errors that Bing found using both modes.

Proof mode Spell mode
{
  "_type": "SpellCheck",
  "flaggedTokens": [
    {
      "offset": 5,
      "token": "its",
      "type": "UnknownToken",
      "suggestions": [
        {
          "suggestion": "it's",
          "score": 0.8048868675051712
        }
      ]
    },
    {
      "offset": 19,
      "token": "turn",
      "type": "RepeatedToken",
      "suggestions": [
        {
          "suggestion": "",
          "score": 0
        }
      ]
    },
    {
      "offset": 36,
      "token": "runing",
      "type": "UnknownToken",
      "suggestions": [
        {
          "suggestion": "running",
          "score": 0.8048868675051712
        }
      ]
    }
  ]
}
{
  "_type": "SpellCheck",
  "flaggedTokens": [
    {
      "offset": 5,
      "token": "its",
      "type": "UnknownToken",
      "suggestions": [
        {
          "suggestion": "it's",
          "score": 1
        }
      ]
    },
    {
      "offset": 36,
      "token": "runing",
      "type": "UnknownToken",
      "suggestions": [
        {
          "suggestion": "running",
          "score": 1
        }
      ]
    }
  ],
  "correctionType": "High"
}

Next steps