2

I have an API I want to invoke that wants something like this to be POSTed in the body: ["foo","bar"]

I have read the official docs and can't see how to do this, is it possible?

I have tried: http --verbose PUT foo.org :='["foo","bar"]' but HTTPie still wants to turn that into a field of a JSON object, with no name, as in:

{
    "": [
        "foo",
        "bar"
    ]
}
greybeard
  • 2,249
  • 8
  • 30
  • 66
Michael Ray Lovett
  • 6,668
  • 7
  • 27
  • 36

1 Answers1

2

The shorthand syntax httpie offers doesn't support empty strings as keys. The easiest option here will be to pass the data via redirected stdin:


$ echo '{"": ["foo","bar"]}' | http --verbose PUT foo.org

See also: Sending nested JSON object using HTTPie

Jakub Roztocil
  • 15,930
  • 5
  • 50
  • 52