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}
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
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 a a screen capture of the App Transport settings
here are the credentials I am using let wdn = Discovery(username: "my-user-name", password: "my-password", version: "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.sstatic.net/5UvJO.png
I created a new app + service, and did not get an unauthorized error. Here are the steps I followed:
I downloaded the Watson Conversation starter from Bluemix. 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).
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.