0

I have been stuck for two days in a very strange issue in Watson Assistant

I have made some code to be able to use it in my app, it keeps giving me 401 authentications error

these are the three services that I have configured in my IBM cloud account

enter image description here

and here is my code to initialize the three service

private fun initSpeechToTextService(): SpeechToText {

        var options = IamOptions.Builder()
            .apiKey(getString(R.string.speech_text_iam_apikey))
            .url(getString(R.string.speech_text_url))
            .build()
        return SpeechToText(options)
    }

private fun initTextToSpeechService(): TextToSpeech {

        var options = IamOptions.Builder()
            .apiKey(getString(R.string.text_speech_iam_apikey))
            .url(getString(R.string.text_speech_url))
            .build()
        return TextToSpeech(options)
    }

private fun initAssistantService(): Assistant {

        var options = IamOptions.Builder()
            .apiKey(getString(R.string.watson_assistant_iam_apikey))
            .url(getString(R.string.watson_assistant_url))
            .build()

        var service = Assistant("2019-07-04", options)
        service.endPoint = getString(R.string.watson_assistant_url)

        return service
    }

my problem now that I always get status: 401, error: Unauthorized

can anyone please tell me what is missing?

EDIT

here are the urls that I am using

EDIT2

here is a screenshot of my debugger windows

enter image description here

Amira Elsayed Ismail
  • 9,216
  • 30
  • 92
  • 175
  • change the api key, or change the url, do you get the same error? (you need to work out if the error is in your code or if its config on the watson website side) – Blundell Jul 05 '19 at 13:53
  • Off-course I did change the API keys, and I have tried many time I do not know exactly where is the problem – Amira Elsayed Ismail Jul 05 '19 at 14:09

1 Answers1

0

The service version for your Assistant is set to 2019-07-04 which is invalid. Check here for the latest and previous versions. Does this work?

var service = Assistant("2019-02-28", options)
    service.endPoint = getString(R.string.watson_assistant_url)
data_henrik
  • 16,724
  • 2
  • 28
  • 49