Spec-Zone.ru › Nushell

http post for network

Send a POST request to a URL with a request body.

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 {duration}: Max duration before timeout occurs.
  • --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.
  • --pool: Using a global pool as a client.
  • --redirect-mode, -R {string}: What to do when encountering redirects. Default: 'follow'. Valid options: 'follow' ('f'), 'manual' ('m'), 'error' ('e').
  • --unix-socket, -U {path}: Connect to the specified Unix socket instead of using TCP.

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 using a record.

> http post --headers {my-header-key: my-header-value} https://www.example.com

Post content to example.com, with custom header using a list.

> http post --headers [my-header-key-A my-header-value-A my-header-key-B my-header-value-B] 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 binary file to example.com.

> http post --content-type multipart/form-data https://www.example.com { file: (open -r file.mp3) }

Convert a text file into binary and upload it to example.com.

> http post --content-type multipart/form-data https://www.example.com { file: (open -r file.txt | into binary) }

Get the response status code.

> http post https://www.example.com 'body' | metadata | get http_response.status

Check response status while streaming.

> http post --allow-errors https://example.com/upload 'data' | metadata access {|m| if $m.http_response.status != 200 { error make {msg: "failed"} } else { } } | lines

Notes

Performs HTTP POST operation.

Copyright © 2019–2026 The Nushell Project DevelopersLicensed under the MIT License.
https://www.nushell.sh/commands/docs/http_post.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API