xf.li | 6c8fc1e | 2023-08-12 00:11:09 -0700 | [diff] [blame^] | 1 | c: Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al. |
| 2 | SPDX-License-Identifier: curl |
| 3 | Long: data |
| 4 | Short: d |
| 5 | Arg: <data> |
| 6 | Help: HTTP POST data |
| 7 | Protocols: HTTP MQTT |
| 8 | See-also: data-binary data-urlencode data-raw |
| 9 | Mutexed: form head upload-file |
| 10 | Category: important http post upload |
| 11 | Example: -d "name=curl" $URL |
| 12 | Example: -d "name=curl" -d "tool=cmdline" $URL |
| 13 | Example: -d @filename $URL |
| 14 | Added: 4.0 |
| 15 | Multi: append |
| 16 | --- |
| 17 | Sends the specified data in a POST request to the HTTP server, in the same way |
| 18 | that a browser does when a user has filled in an HTML form and presses the |
| 19 | submit button. This will cause curl to pass the data to the server using the |
| 20 | content-type application/x-www-form-urlencoded. Compare to --form. |
| 21 | |
| 22 | --data-raw is almost the same but does not have a special interpretation of |
| 23 | the @ character. To post data purely binary, you should instead use the |
| 24 | --data-binary option. To URL-encode the value of a form field you may use |
| 25 | --data-urlencode. |
| 26 | |
| 27 | If any of these options is used more than once on the same command line, the |
| 28 | data pieces specified will be merged with a separating &-symbol. Thus, using |
| 29 | '-d name=daniel -d skill=lousy' would generate a post chunk that looks like |
| 30 | 'name=daniel&skill=lousy'. |
| 31 | |
| 32 | If you start the data with the letter @, the rest should be a file name to |
| 33 | read the data from, or - if you want curl to read the data from stdin. Posting |
| 34 | data from a file named 'foobar' would thus be done with --data @foobar. When |
| 35 | --data is told to read from a file like that, carriage returns and newlines |
| 36 | will be stripped out. If you do not want the @ character to have a special |
| 37 | interpretation use --data-raw instead. |