Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

curl xput windows Couldn't read data from file

Tags:

json

curl

cmd

solr

I am using cURL in windows using command propmpt. When I am executing this command:

curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@/path/myFeatures.json" -H "Content-type:application/json"

I am getting following error:

Warning: Couldn't read data from file "/path/myFeatures.json", this makes an
Warning: empty POST.

I have updated the file permissions and file is also present at the specific path.

What can be the possible solutions?

like image 520
pankaj kashyap Avatar asked Apr 19 '17 13:04

pankaj kashyap


2 Answers

If you really have a file named myFeatures.json into a folder named path in the current folder where you're trying to submit curl, just remove the leading slash from the path.

curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@path/myFeatures.json" -H "Content-type:application/json"

On the other hand, try to specify the absolute path to your myFeatures.json.

curl -XPUT "localhost:8983/solr/techproducts/schema/feature-store" --data-binary "@C:\your\complete\path\myFeatures.json" -H "Content-type:application/json"
like image 66
freedev Avatar answered Oct 25 '22 15:10

freedev


I had the same problem, and in my case, it turned out that this was caused by using ~ in my path.

like image 32
not2savvy Avatar answered Oct 25 '22 15:10

not2savvy