pankaj kashyap
pankaj kashyap

Reputation: 382

curl xput windows Couldn't read data from file

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?

Upvotes: 13

Views: 30445

Answers (3)

not2savvy
not2savvy

Reputation: 4243

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

Upvotes: 4

Maciek Leks
Maciek Leks

Reputation: 1448

The simplest solution is to change the extension of a file from ".json" to ".txt".

Upvotes: -4

freedev
freedev

Reputation: 30087

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"

Upvotes: 17

Related Questions