我正在尝试使用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);
});
}```
答案 0 :(得分:1)
您的回调URL中的主机名似乎是127.0.0.1
,它不是公共主机名,而是回送接口的地址。