http post
for network
Post a body to a URL.
Signature
> http post {flags} (URL) (data)
Flags
--user, -u {any}
: the username when authenticating--password, -p {any}
: the password when authenticating--content-type, -t {any}
: the MIME type of content to post--max-time, -m {int}
: timeout period in seconds--headers, -H {any}
: custom headers you want to add--raw, -r
: return values as a string instead of a table--insecure, -k
: allow insecure server connections when using SSL--full, -f
: returns the full response instead of only the body--allow-errors, -e
: do not fail if the server returns an error code--redirect-mode, -R {string}
: What to do when encountering redirects. Default: 'follow'. Valid options: 'follow' ('f'), 'manual' ('m'), 'error' ('e').
Parameters
URL
: The URL to post to.data
: The contents of the post body. Required unless part of a pipeline.
Input/output types:
input | output |
---|---|
any | any |
Examples
Post content to example.com
> http post https://www.example.com 'body'
Post content to example.com, with username and password
> http post --user myuser --password mypass https://www.example.com 'body'
Post content to example.com, with custom header
> http post --headers [my-header-key my-header-value] https://www.example.com
Post content to example.com, with JSON body
> http post --content-type application/json https://www.example.com { field: value }
Post JSON content from a pipeline to example.com
> open --raw foo.json | http post https://www.example.com
Upload a file to example.com
> http post --content-type multipart/form-data https://www.example.com { audio: (open -r file.mp3) }
Notes
Performs HTTP POST operation.