繁体   English   中英

从AlchemyNews迁移到Watson Discovery会在Swift V3中出现401错误com.ibm.watson.developer-cloud.DiscoveryV1 Code = 401

[英]Migration from AlchemyNews to Watson Discovery gives 401 error in Swift V3 com.ibm.watson.developer-cloud.DiscoveryV1 Code=401

您好我已经从AlchemyAPI转移到DiscoveryV1但是我的swift程序收到401错误,rror Domain = com.ibm.watson.developer-cloud.DiscoveryV1 Code = 401“Not Authorized”UserInfo = {NSLocalizedFailureReason = Not Authorized}

在迁移到Discovery之前,该应用程序运行良好,Bluemix支持团队已经验证了凭据,并且在BLuemix中运行查询时没有收到任何错误

为了它,我还将网址添加到App传输安全设置,这是一个猜测,但它没有改变我添加了一个应用程序传输设置的屏幕截图的错误

这里是我使用的凭据让wdn = Discovery(用户名:“my-user-name”,密码:“my-password”,版本:“2017-03-08”)

let environmentID = "envID generated under my account on bluemix"
let collectionID = "collectionID generated under my account on bluemix"
let filter = ""
let query = newsSearchString < variable set later
let aggregation = "term(enriched_text.concepts.text).top_hits(10)"
let numberOfItemsToReturn = 30
let failure = { (error: Error) in print(error) }
let returnEntities = "enriched.url.url,enriched.url.title,enriched.url.author"




[enter image description here][1]


  [1]: https://i.stack.imgur.com/5UvJO.png

我创建了一个新的应用程序+服务,并没有得到未经授权的错误。 以下是我遵循的步骤:

码 应用传输安全设置

  1. 从Bluemix下载了Watson Conversation启动器 这包括一个轻量级的Watson项目,其中包括快速设置所需的SDK和设置(基本上您所要做的就是将您的凭据放在Converation服务的配置文件中)。

  2. 因为该启动器已经设置了所有Watson配置,所以我只导入了DiscoveryV1服务,将Framework拖到我的项目中(更新了Build阶段),并输入了初始化代码段,一切都对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM