簡體   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