github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/docs/commands/post.md (about) 1 # `post` 2 3 > HTTP POST request with a JSON-parsable return 4 5 ## Description 6 7 Fetches a page from a URL via HTTP/S POST request. 8 9 ## Usage 10 11 ``` 12 post url -> <stdout> 13 14 <stdin> -> post url content-type -> <stdout> 15 ``` 16 17 ## Examples 18 19 ``` 20 ยป post google.com -> [ Status ] 21 { 22 "Code": 405, 23 "Message": "Method Not Allowed" 24 } 25 ``` 26 27 ## Detail 28 29 ### JSON return 30 31 `POST` returns a JSON object with the following fields: 32 33 ``` 34 { 35 "Status": { 36 "Code": integer, 37 "Message": string, 38 }, 39 "Headers": { 40 string [ 41 string... 42 ] 43 }, 44 "Body": string 45 } 46 ``` 47 48 The concept behind this is it provides and easier path for scripting eg pulling 49 specific fields via the index, `[`, function. 50 51 ### `post` as a method 52 53 Running `post` as a method will transmit the contents of STDIN as part of the 54 body of the HTTP POST request. When run as a method you have to include a second 55 parameter specifying the Content-Type MIME. 56 57 ### Configurable options 58 59 `post` has a number of behavioral options which can be configured via Murex's 60 standard `config` tool: 61 62 ``` 63 config -> [ http ] 64 ``` 65 66 To change a default, for example the user agent string: 67 68 ``` 69 config set http user-agent "bob" 70 post google.com 71 ``` 72 73 This enables sane, repeatable and readable defaults. Read the documents on 74 `config` for more details about it's usage and the rational behind the command. 75 76 ## See Also 77 78 * [`[ Index ]`](../parser/item-index.md): 79 Outputs an element from an array, map or table 80 * [`[[ Element ]]`](../parser/element.md): 81 Outputs an element from a nested structure 82 * [`config`](../commands/config.md): 83 Query or define Murex runtime settings 84 * [`get`](../commands/get.md): 85 Makes a standard HTTP request and returns the result as a JSON object 86 * [`getfile`](../commands/getfile.md): 87 Makes a standard HTTP request and return the contents as Murex-aware data type for passing along Murex pipelines. 88 89 <hr/> 90 91 This document was generated from [builtins/core/httpclient/post_doc.yaml](https://github.com/lmorg/murex/blob/master/builtins/core/httpclient/post_doc.yaml).