Mohsen Mahmoud
Mohsen Mahmoud

Reputation: 31

Invalid Request : Content is Empty

I'm just starting with cURL, I'm using Watson Natural Language Understanding (NLU) Service.. the following line gives me error code:400 "Invalid Request, content is Empty"

Note: I'm a Windows User

Your help is greatly appreciated!

All I'm trying to do is this simple Getting Started Example

https://cloud.ibm.com/services/natural-language-understanding/crn:v1:bluemix:public:natural-language-understanding:us-south:a%2f1fdc918bf6c243fcb853ba8fb6907839:aaf7bfd6-ca63-431a-a143-e2cc863ebc6c::?paneId=gettingStarted

curl -X POST -u "apikey:{MY_API_KEY}" ^
"https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-11-16" ^

Upvotes: 0

Views: 1725

Answers (1)

Shranith linga
Shranith linga

Reputation: 26

Hey @mohsen the body is missing in the above Post request, A sample request would look something like this for Keywords on a text, Also replace API-KEY in the below curl request. It is not ideal to post API Keys in public sites

curl -X POST \
 'https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2017-01-11' \
-u "apikey:<API-KEY>"\
 -H 'Content-Type: application/json' \
 -H 'cache-control: no-cache' \
 -d '{
   "text":"Iran Warns Of Retaliation If U.S. Breaches Nuclear Deal. Iran Supreme Leader Ayatollah Khamenei is warning that Tehran will retaliate if the sanctions are approved.",
   "features": {
       "keywords":{
           "sentiment":true

       }
   },
   "language":"en"

}'

Upvotes: 1

Related Questions