Reputation: 613
Using curl request
curl -v -X PATCH -H "Content-Type:multipart/form-data" -H "Accept:application/json" -H "Auth-token:abcde" -F "first_name=snme" -F 'tags[]=chec' -F 'tags[]=chec2' http://example.com/api/users/1
I want to post tags as an array. So parsing the request i should get tags = ['check' , 'check2']
etc.
What I get now is {"tags[]" = "chec"}
Upvotes: 15
Views: 20352
Reputation: 2863
For some server, you can use
curl -X POST -F 'tags=check1' -F 'tags=check2' 'http://example.com/api/users/1' -v
Upvotes: 2
Reputation: 176
For me on BASH is work like this:
curl -X POST -H 'Content-Type: multipart/form-data' -F "email="$EMAIL"" https://slack.com/api/users.admin.invite?token=$TOKEN&t=$DATE&first_name=$F1&last_name=$F2
Upvotes: -1
Reputation: 276
Try this:
curl -X POST -d 'tags[]=check&tags[]=check2' 'http://example.com/api/users/1' -v
For multipart it should work with what you have tried:
curl -X POST -F 'tags[]=check1' -F 'tags[]=check2' 'http://example.com/api/users/1' -v
Returns:
{"tags":["chec","chec2"], ... }
Upvotes: 19