简体   繁体   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

Hello I have moved over from AlchemyAPI to DiscoveryV1 but my swift program is getting a 401 error, rror Domain=com.ibm.watson.developer-cloud.DiscoveryV1 Code=401 "Not Authorized" UserInfo={NSLocalizedFailureReason=Not Authorized} 您好我已经从AlchemyAPI转移到DiscoveryV1但是我的swift程序收到401错误,rror Domain = com.ibm.watson.developer-cloud.DiscoveryV1 Code = 401“Not Authorized”UserInfo = {NSLocalizedFailureReason = Not Authorized}

The app was working fine before moving to Discovery and the Bluemix support team have verified the credentials and get no error when running the query in BLuemix 在迁移到Discovery之前,该应用程序运行良好,Bluemix支持团队已经验证了凭据,并且在BLuemix中运行查询时没有收到任何错误

for the sake of it I also added the url into the App transport Security settings which was a guess but it didn't change the error I have added aa screen capture of the App Transport settings 为了它,我还将网址添加到App传输安全设置,这是一个猜测,但它没有改变我添加了一个应用程序传输设置的屏幕截图的错误

here are the credentials I am using let wdn = Discovery(username: "my-user-name", password: "my-password", version: "2017-03-08") 这里是我使用的凭据让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

I created a new app + service, and did not get an unauthorized error. 我创建了一个新的应用程序+服务,并没有得到未经授权的错误。 Here are the steps I followed: 以下是我遵循的步骤:

码 应用传输安全设置

  1. I downloaded the Watson Conversation starter from Bluemix . 从Bluemix下载了Watson Conversation启动器 This includes a lightweight Watson project which includes the SDKs and settings necessary to get set up quickly (essentially all you have to do is put your credentials in a config file for the Converation service). 这包括一个轻量级的Watson项目,其中包括快速设置所需的SDK和设置(基本上您所要做的就是将您的凭据放在Converation服务的配置文件中)。

  2. Because that starter has all of the Watson configuration set up, I just imported the DiscoveryV1 service, dragged the Framework over to my project (updated the Build Phase), and typed in the initialization snippet and everything is working for me. 因为该启动器已经设置了所有Watson配置,所以我只导入了DiscoveryV1服务,将Framework拖到我的项目中(更新了Build阶段),并输入了初始化代码段,一切都对我有用。

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

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