Search code examples
ibm-cloudspeech-to-textibm-watson

Watson Speech-to-Text register_callback returns only 400s


The Watson Speech-to-Text asynchronous HTTP interface allows one to register a callback url through a call to register_callback. This call is clearly not working; for illustration, please see these six lines of code.

# Illustration of how I can't get the Watson Speech-to-Text
# register_callback call to work.

r = requests.post(
    "https://stream.watsonplatform.net/speech-to-text/api/v1/register_callback?{0}".format(
        urllib.urlencode({ "callback_url": callback_url })),
    auth=(watson_username, watson_password),
    data="{}")

print(r.status_code)
print(pprint.pformat(r.json()))

# This outputs:

# 400
# {u'code': 400,
#  u'code_description': u'Bad Request',
#  u'error': u"unable to verify callback url 'https://xuyv2beqpj.execute-api.us-east-1.amazonaws.com/prod/SpeechToTextCallback' , server responded with status code: 400"}

# and no http call is logged on the server.

r = requests.get(
    callback_url, params=dict(challenge_string="what does redacted mean?"))

print(r.status_code)
print(r.text)

# This outputs:

# 200
# what does redacted mean?

# and an HTTP GET is logged on the server.

I first call register_callback with a perfectly valid callback_url parameter, in exactly the way the documentation describes. This call returns with a 400 and, according to my callback URL server logs, the callback URL never receives an HTTP request. Then I GET the callback URL myself with a challenge_string. Not only is the callback URL responding with the right output, but a log appears on my server indicating the URL received an HTTP request. I conclude that register_call is not working.


Solution

  • Answer:

    We identified the issue on our end: the server that makes the outbound calls to your URL did not support the SSL encryption method that your callback server uses. We have fixed that and we are in the process of pushing to the production environment very soon.

    Also FYI:

    The error message with 400 indicates the callback URL does not meet request or does not exist. Please refer to the detail in Speech-To-Text service API document, http://www.ibm.com/watson/developercloud/speech-to-text/api/v1/?curl#register_callback

    If the service does not receive a response with a response code of 200 and a body that echoes a random alphanumeric challenge string from the callback URL within 5 seconds, it does not whitelist the URL; it sends response code 400 in response to the registration request.