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

末鹿安然 提交于 2020-01-23 18:54:06

问题


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

回答1:


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"


来源:https://stackoverflow.com/questions/13368316/how-to-do-a-http-post-a-list-of-value-using-curl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!