使用带有curl的相对路径发送JSON文件
我有一个名为使用带有curl的相对路径发送JSON文件,json,rest,curl,Json,Rest,Curl,我有一个名为people.JSON的JSON文件: [ { "name": "Adam" }, { "name": "Eve" } ] 我正在尝试使用带有curl的POST请求从项目的根目录发送此数据: curl --request POST \ --header 'Content-Type: application/json' 'Acce
people.JSON的JSON文件:
[
{
"name": "Adam"
},
{
"name": "Eve"
}
]
我正在尝试使用带有curl
的POST请求从项目的根目录发送此数据:
curl --request POST \
--header 'Content-Type: application/json' 'Accept: application/json' \
--data-binary @src/test/java/com/spring/app/people.json \
http://127.0.0.1:8080/api/v1/person -v -s
我不断收到“错误请求”错误:
*正在关闭连接-1
*正在尝试127.0.0.1:8080。。。
*连接到127.0.0.1(127.0.0.1)端口8080(#0)
>POST/api/v1/person HTTP/1.1
>主持人:127.0.0.1:8080
>用户代理:curl/7.74.0
>接受:*/*
>内容类型:application/json
>内容长度:80
>
*上传已完全发送:80个字节中有80个
*将捆绑包标记为不支持多用途
我已经看过了,但仍然得到相同的错误。
我还安装了自制curl
,但即使使用它也不能解决错误
我将感谢任何帮助
* Closing connection -1
* Trying 127.0.0.1:8080...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /api/v1/person HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.74.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 80
>
* upload completely sent off: 80 out of 80 bytes
* Mark bundle as not supporting multiuse
< HTTP/1.1 400
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Sat, 12 Dec 2020 03:56:38 GMT
< Connection: close
<
* Closing connection 0
{"timestamp":"2020-12-12T03:56:38.822+00:00","status":400,"error":"Bad Request","message":"","path":"/api/v1/person"}%