Sending nested JSON object using HTTPie

Update for HTTPie 3.0 released in January 2022:

There’s now built-in support for nested JSON using the HTTPie language:

$ http pie.dev/post \
  tool[name]=HTTPie \
  tool[about][homepage]=httpie.io \
  tool[about][mission]='Make APIs simple and intuitive' \
  tool[platforms][]=terminal \
  tool[platforms][]=desktop \
  tool[platforms][]=web \
  tool[platforms][]=mobile 
{
    "tool": {
        "name": "HTTPie",
        "about": {
            "mission": "Make APIs simple and intuitive",
            "homepage": "httpie.io"
        },
        "platforms": [
            "terminal",
            "desktop",
            "web",
            "mobile"
        ]
    }
}

You can learn more about nested JSON in the docs: https://httpie.io/docs/cli/nested-json


Old answer for HTTPie older than 3.0:

You can pass the whole JSON via stdin:

$ echo '{ "user": { "name": "john", "age": 10 } }' | http httpbin.org/post

Or specify the raw JSON as value with :=:

$ http httpbin.org/post user:='{"name": "john", "age": 10 }'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)