0
votes

I've followed through the guide written here https://docs.microsoft.com/en-us/azure/cognitive-services/bing-spell-check/quickstarts/python, but I'm getting a 404 error code. This is the code from the guide:

import requests
import json

api_key = myke
example_text = "Hollo, wrld" # the text to be spell-checked
endpoint = "https://api.cognitive.microsoft.com/bing/v7.0/SpellCheck"
data = {'text': example_text}
params = {
    'mkt':'en-us',
    'mode':'spell'
    }

headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'Ocp-Apim-Subscription-Key': api_key,
    }

response = requests.post(endpoint, headers=headers, params=params, data=data)
json_response = response.json()
print(json.dumps(json_response, indent=4))

But when I create a resource, the endpoint I get is either https://api.bing.microsoft.com/ or https://spellcheck3.cognitiveservices.azure.com/ depending on the guide.

How do I correctly run this code?

1

1 Answers

0
votes

The code as written in the guide doesn't seem to work; here's a solution I found.

search_url = "https://api.bing.microsoft.com/v7.0/spellcheck"

search_term = "wrld helath"
params = {
    'mkt':'en-us',
    'mode':'spell',
    'text' : search_term
    }
headers = {"Ocp-Apim-Subscription-Key": subscription_key}
response = requests.get(search_url, headers=headers, params=params)
response.raise_for_status()
search_results = response.json()