how to do a HTTP POST a list of value using cURL

2019-06-01 19:22发布

how I do post multiple values to the same key using cURL?

for example when I ran the following to my example.com URL, it complained...is the format correct or is this a problem with the backend not being able to handle the request?

curl -k -H 'Accept: application/json' --user admin:admin example.com -d name=peter -d name=paul -d name=mary

标签: http post curl
1条回答
虎瘦雄心在
2楼-- · 2019-06-01 19:54

Multiple -d looks fine. The docs said -d name=daniel -d skill=lousy will generate name=daniel&skill=lousy

http://curl.haxx.se/docs/manpage.html#-d

So if you want send an array, you have to use the [] brackets.

-d name[]=peter -d name[]=paul -d name[]=mary

It looks like you can also use

-d "name[]=peter&name[]=paul&name=mary"
查看更多
登录 后发表回答