How do you pass an array to the api

On some of the api calls, you are expected to pass an array of values in the post data. How do you do this?

I have figured out by trial an error how to pass an array with one item in it - e.g. for change-owner, you want something like:

username: sean-finnegan
post_ids[]: 925

(or, in url-encoded)

post_ids%5B%5D=925&username=sean-finnegan
2 Likes

Great question, I agree that can be a bit confusing. If you want to pass multiple post_ids you would pass in multiple form data fields for post_ids[] like this curl example:

curl -i -sS -X POST "http://localhost:8080/t/15/change-owner.json" 
-H "Api-Key: api-key" \
-H "Api-Username: system" \
-F "username=blake" \
-F "post_ids[]=29" \
-F "post_ids[]=30"
4 Likes