后端编码如下:
@POST
@Path("/resource")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response dailyBilling(
final List<String> students)
throws Exception {
....
}
Run Code Online (Sandbox Code Playgroud)
我应该如何发送curl数据,我会在后端接受列表?
使用以下curl我得到400:
curl --digest -u ameya379+beet@gmail.com:credentials\
-H 'Content-Type: application/json'\
-X POST -d '{"student1", "student2"}'\
http://localhost:8080/api/somepath/resource
Run Code Online (Sandbox Code Playgroud)
错误:
{
"detail":"Received JSON does not match expected format.",
"error":400,
"errorCode":"INVALID_JSON",
"parameters":[],
"reason":"Bad Request"
}
Run Code Online (Sandbox Code Playgroud)
数组[]在JSON 之间编码.
curl --digest -u ameya379+beet@gmail.com:credentials -H 'Content-Type: application/json' -X POST -d '["student1", "student2"]' http://localhost:8080/api/somepath/resource
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
380 次 |
| 最近记录: |