Just wondering how I can send a curl command with the -d option specifying a file with its path and not a file in the current directory.
This is what I'm getting when I try to test my app with the json file in the local dir. Both the app and myself are happy:
curl -XPOST -H 'Content-Type:application/json' -d @all_fields.json http://testcomp.lab.net:8080/stats -v -s
* About to connect() to testcomp.lab.net port 8080
* Trying 10.93.2.197... connected
* Connected to testcomp.lab.net (10.93.2.197) port 8080
> POST /stats HTTP/1.1
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: testcomp.lab.net:8080
> Accept: */*
> Content-Type:application/json
> Content-Length: 2882
> Expect: 100-continue
>
< HTTP/1.1 100 Continue
HTTP/1.1 200 OK
< Content-Length: 0
* Connection #0 to host testcomp.lab.net left intact
* Closing connection #0
This is what I'm getting when I specify a json file that's in another directory
curl -XPOST -H 'Content-Type:application/json' -d @json/all_fields.json http://testcomp.lab.net:8080/stats -v -s
"Invalid json for Java type interface java.util.List"
Warning: Couldn't read data from file "json/all_fields.json", this makes an
Warning: empty POST.
<snip snip>
<snip snip>
< HTTP/1.1 400 Bad Request
< Content-Type: application/json
< Transfer-Encoding: chunked
* Connection #0 to host testcomp.lab.net left intact
* Closing connection #0
I didn't see anything in the man page for curl for specifying directories for files passed in as data. Am I unfortunately limited to files in the local directory or is there a special way to specify files in different directories? Thanks in advance for your help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…