Bing Spell Check API doesn't return any results on Google App Engine

Timothee 0 Reputation points
2023-06-23T15:22:28.4966667+00:00

Hi,

After running the same code locally and on Google App Engine, I've realized that Bing Spell Check API doesn't return any results on Google App Engine. Instead, the response is always:

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

The text I was testing is "Strong understnding of Datbase architcture", which returns flagged tokens locally but not on Google App Engine. Could it be that some IP addresses are being blocked?

The code is quite straighforward:

    httpClient := &http.Client{}
	formData := url.Values{}
	formData.Set("text", text)
	formData.Set("mkt", "en-UK")
	payload := strings.NewReader(formData.Encode())
	req, err := http.NewRequest("POST", bingSpellCheckURL, payload)
	if err != nil {
		log.Printf("Failed to create POST request for Bing Spell Check API: %v\n", err)
		return
	}
	req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
	req.Header.Set("Ocp-Apim-Subscription-Key", bingSpellCheckToken)

	resp, err := httpClient.Do(req)
	if err != nil {
		log.Printf("Fail to send POST request Bing Spell Check API: %v\n", err)
		return
	}
	defer resp.Body.Close()

	// Read the request body
	data, err := ioutil.ReadAll(resp.Body)
    fmt.Printf("Bing text is %v\n", text)  
    fmt.Printf("Bing response is %v\n", string(data))

I've tried dozens of times, and I'm always getting different results locally and on Google App Engine.

Let me know if you need more information.

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