I was trying the sample examples of various features documented at https://cloud.ibm.com/apidocs/natural-language-understanding. All the features examples are working properly except the Sentiment feature while trying with Curl.
curl -X POST \
-H "Content-Type: application/json" \
-u "apikey:{apikey}" \
-d @parameters.json \
"{url}/v1/analyze?version=2018-11-16"
parameters.json
{
"url": "www.wsj.com/news/markets",
"features": {
"sentiment": {
"targets": [
"stocks"
]
}
}
}
Sentiment feature response:
{
"language": "en",
"error": "target(s) not found",
"code": 400
}
Here's how it worked for me. Explaining in an elaborate way to help others.
First of all, you have to create a file named
parameters.jsonand paste the below codePointing to the folder in which this JSON file is on a terminal or command prompt and replacing the
{apikey}and{URL}with the NLU service values, run the below commandThe {URL} in my case is
https://gateway.watsonplatform.net/natural-language-understanding/apiThen should see the below output