Reputation: 662
Here is my request:
> curl -i -H "Accept: application/json" -H "Content-Type:
> application/json" -X GET
> http://access.alchemyapi.com/calls/image/ImageGetRankedImageKeywords?apikey=<key>&image=file%3A%2F%2Ftmp%2Fimage.jpg&imagePostMode=not-raw&outputMode=json
Following http://www.alchemyapi.com/api/image-tagging/image.html
Response:
HTTP/1.1 200 OK Server: nginx Date: Wed, 13 May 2015 04:27:56 GMT Content-Type: application/xml; charset=utf-8 Content-Length: 440 Connection: keep-alive Cache-Control: no-cache X-AlchemyAPI-CurrentVersion: 12.15 X-AlchemyAPI-Error-Msg: content-is-empty X-AlchemyAPI-Key: X-AlchemyAPI-Params: sentiment=0&knowledgeGraph=0&detectedLanguage=unknown&submitLanguage=detect X-AlchemyAPI-Status: ERROR X-AlchemyAPI-Total-Transactions: 4 Access-Control-Allow-Origin: *
ERROR content-is-empty By accessing AlchemyAPI or using information generated by AlchemyAPI, you are agreeing to be bound by the AlchemyAPI Terms of Use: http://www.alchemyapi.com/company/terms.html 4
Why? The image exists:
$ ls -l /tmp/trash1.jpg
-rw-r-----@ 1 xx staff 47846 May 12 15:49 /tmp/image.jpg
$
Upvotes: 0
Views: 409
Reputation: 662
Their support helped me. Essentially i need to POST the image directly. Can't use the "image" parameter and filling it with the name of the local file. That parameter actually needs to contain the contents of the image file instead. So instead need to use imagePostMode=raw, and just add the file as the post body, which I would recommend. Something like this:
wget -qO- --post-file YOUR_IMAGE.png "http://access.alchemyapi.com/calls/image/ImageGetRankedImageKeywords?apikey=API_KEY&imagePostMode=raw"
Upvotes: 1