watson-developer-cloud / swift-sdk

:iphone: The Watson Swift SDK enables developers to quickly add Watson Cognitive Computing services to their Swift applications.
https://watson-developer-cloud.github.io/swift-sdk/
Apache License 2.0
877 stars 222 forks source link

[Conversation] Error while decoding Json in Swift #585

Closed KopalKothari closed 7 years ago

KopalKothari commented 7 years ago

I am working on Swift 3

SwiftConversationPrj.zip

When you open an issue for a feature request, please add as much detail as possible:

KopalKothari commented 7 years ago

Can you please let me know if more information is needed to reproduce the issue. Thanks!

sccheng commented 7 years ago

Hi @KopalKothari, I'm looking into this today. I'll let you know if I run into any problems reproducing your issue!

sccheng commented 7 years ago

Hi @KopalKothari,

So I took a look, and it turns out that as of September 20, 2016, the Conversation service was updated so that the Context model's dialog_stack is no longer an array of strings. It's now an array of JSON objects. This is documented in the release notes.

The reason that you're seeing the unexpectedSubscript(Swift.String) error is because our SDK is expecting an array of JSON objects rather than an array of strings, like you're receiving right now. You're probably receiving the old model because you currently specify "2016-07-11" as your version date.

You can fix the error by updating your main.swift so that, on line 10, you're using version "2016-09-20" or later.

As a side note, thank you very much for attaching your project, it was extremely helpful in the debugging process!! I do want to remind you to make sure you reset your credentials though, as your credentials were attached in the file!

I'll go ahead and close this issue now, since I believe that updating your version date will fix the errors you're seeing.

KopalKothari commented 7 years ago

Thanks Stephanie for the help! The error is no more there once I change the version. Thanks!