3

I want to send a curl post request with query params. One of these params is an array of strings. An example for such a string (using Postman chrome extension):

http://www.example.com/my_rest_endpoint?start=123456&duration=11&array_param=["activity level"]

Now, how can I translate this request to a curl command? no matter what I do, I can't seem to send the last parameter, array_param to curl. I've tried escaping the quotes and/or brackets with \, tried using -i flag and other various options, all with no success.

2 Answers 2

4

Solution was very close to what benaryorg suggested: Brackets and spaces needs to be placed with %5B, %5D and + according to the url encoding. The quotes were escaped using \". The final result is:

http://www.example.com/my_rest_endpoint?start=123456&duration=11&array_param=%5B\"Activity+Level\"%5D".

Sign up to request clarification or add additional context in comments.

1 Comment

Turns out there's no standard encoding of array of strings. It seems the awful array_param%5B%5D=Activity+Level is more likely to work. See willhaley.com/blog/url-array-go
2

Have you tried placing ' around the parameters instead of escaping?

Also if that does not work, you could try to escape them like this example from Wikipedia.

You can find the codes for encoding here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.