Neil
Neil

Reputation: 5178

IBM Watson Tone Analyzer Invalid JSON Error

I must be missing something very simple here. I am following the Example Tutorial Instructions. I already created a free account and I have my API key and the URL. I copied the JSON file as instructed. Here is the command I issued:

curl -X POST -u "apikey:MY-API-KEY" \
--header "Content-Type: application/json" \
--data-binary PATH-TO-FILE \
"MY-URL"

Here is the error I am getting:

{"code":400,"sub_code":"C00012","error":"Invalid JSON input at line 1, column 2"}

I copied the JSON exactly from the directions:

{
  "text": "Team, I know that times are tough! Product sales have been disappointing for the past three quarters. We have a competitive product, but we need to do a better job of selling it!"
}

I also attempted the following JSON and it received the same error:

{"text":"Hello world"}

What obvious thing am I missing here?

Upvotes: 0

Views: 135

Answers (1)

Neil
Neil

Reputation: 5178

I knew it was going to be something silly.

The directions have this as an example:

curl -X POST -u "apikey:{apikey}" \
--header "Content-Type: application/json" \
--data-binary @{path_to_file}tone.json \
"{url}/v3/tone?version=2017-09-21"

For the path to the file, I had to keep the @ symbol in front. so let's assume the full path to the file is /home/joe/Desktop/tone.json, that line has to be:

--data-binary @/home/joe/Desktop/tone.json \

Upvotes: 0

Related Questions