难以使用 IBM watson 语音到文本 npm 模块注册回调 url

Difficulty registering callback url with IBM watson speech-to-text npm module

我正在尝试使用 express 为 IBM speechToText 服务注册回调 url,但在调用 speechToText.registerCallback.

时,我不断收到 400 响应

我已经确保 url 存在并且正在通过 Postman 提供预期的响应。我还知道我的 SpeechToText 服务具有正确的凭据。

当我使用 registerCallback 调用端点时,我没有看到记录的 'challenge_string'。

router.get('/callback', (req,res,next) => {
    console.log(req.query.challenge_string);
    return res.status(200);
});

router.post('/newStream', (req,res) => {

var speechToText = new SpeechToTextV1({
        username: <my_username>,
        password: <my_password>,
        url: 'https://stream.watsonplatform.net/speech-to-text/api/'
      });

    const registerCallbackParams = {
        callback_url: 'http://127.0.0.1:8080/callback',
        user_secret: 'ThisIsMySecret',
    };

    speechToText.registerCallback(registerCallbackParams)
    .then(registerStatus => {
        console.log(JSON.stringify(registerStatus, null, 2));
    })
    .catch(err => {
        console.log(registerCallbackParams);
        console.log('error:', err);
    }); 

}```

您的回调 url 中的主机名似乎是 127.0.0.1,那不是 public 主机名,而是环回接口的地址。