Why do I keep getting 415 WatsonException: Error: unsupported media type in Python?

344
April 10, 2017, at 1:55 PM

I am trying to use Watson api for sentiment analysis. The code is quite simple. But why do I keep getting this error?????

WatsonException: Error: unsupported media type, Code: 415

Nothing about this error in API document.

from watson_developer_cloud import AlchemyLanguageV1
alchemy_language = AlchemyLanguageV1(url="https://gateway.watsonplatform.net/natural-language-understanding/api",
          username="xxx",
          password="xxx")
print(json.dumps(alchemy_language.sentiment(text="hehe")))
Answer 1

Please look carefully on the sample code. First of all, it constructs an AlchemyLanguageV1 object using an API key, not login and password, maybe that is the cause?

READ ALSO
Printing a word from a file that is misspelled in Python

Printing a word from a file that is misspelled in Python

So I am looking to print out the words from a sample file that are misspelled and I cant seem to figure out how to loop through 2 lists togetherHere's the code: (the top is just a helper function) and dict

252
How can I add multiple keys to a python Dictionary?

How can I add multiple keys to a python Dictionary?

I have a web scraper that grabs info and saves it to a databaseI use the following code to save data

348
Python iterating list of dates

Python iterating list of dates

I have 10 years data with one file for each dayEach file has a name like this:

334