Bing拼写检查API返回"请求参数丢失"错误

时间:2016-09-26 16:35:27

标签: curl microsoft-cognitive

我正在尝试使用Bing的拼写检查API并继续遇到此错误:

{"_type": "ErrorResponse", "errors": [{"code": "RequestParameterMissing", "message": "Required parameter is missing.", "parameter": "text"}]}% 

我正在使用curl发送请求,并将其格式化为:

curl -v -X POST "https://api.cognitive.microsoft.com/bing/v5.0/spellcheck/?mode=Spell" -H "Content-Type: application/x-www/form-urlencoded" -H "Ocp-Apim-Subscription-Key: XXXXXXXXXXXXXXXXXXXX" --data-ascii "Text=Hello+Werld"

我真的不确定这里的问题是什么,所以任何帮助都会受到赞赏...提前致谢。

此外,这是我在微软网站上看到的例子: https://dev.cognitive.microsoft.com/docs/services/56e73033cf5ff80c2008c679/operations/56e73036cf5ff81048ee6727

1 个答案:

答案 0 :(得分:2)

请尝试:

def spiral(X, Y):
    x = y = 0
    dx = 0
    dy = 1
    for i in range(max(X, Y)**2):
        if (-X/2 < x <= X/2) and (-Y/2 < y <= Y/2):
            print (x, y)
            # DO STUFF...
        if x == -y or (x < 0 and x == y) or (x > 0 and x-1 == y):
            dx, dy = dy, -dx
        x, y = x+dx, y+dy

请注意,curl -v POST "https://api.cognitive.microsoft.com/bing/v5.0/spellcheck?mode=spell" -H "Ocp-Apim-Subscription-Key: $OXFORD_SPELL_KEY" --form "Text=Hello+Werld" 必须为小写,并且必须指定表单字段。