I want to send this JSON using HTTPie:
{
name: 'John',
phones: [
1234,
5678
]
}
And this is the parameters that I add to the httpie
command:
name=John phones[]:=1234 phones[1]:5678
However, it does not compile (shows error).
If I remove those colons:
name=John phones[]=1234 phones[1]=5678
It works, but I get this JSON being sent as the body:
{
"name": "John",
"phones[][1]": "1234",
"phones[][]": "5678"
}
How can I get that body? What parameters should I provide?
There's no need for the index, try:
name='John' \
phones[]=1234 \
phones[]= 5678 \
The :=
in your first try indicated 'Raw JSON fields', so if you'd like to use that, use:
phones:='[1234, 5678]'