data.md (1854B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Long: data 5 Short: d 6 Arg: <data> 7 Help: HTTP POST data 8 Protocols: HTTP MQTT 9 Mutexed: form head upload-file 10 Category: important http post upload 11 Added: 4.0 12 Multi: append 13 See-also: 14 - data-binary 15 - data-urlencode 16 - data-raw 17 Example: 18 - -d "name=curl" $URL 19 - -d "name=curl" -d "tool=cmdline" $URL 20 - -d @filename $URL 21 --- 22 23 # `--data` 24 25 Send the specified data in a POST request to the HTTP server, in the same way 26 that a browser does when a user has filled in an HTML form and presses the 27 submit button. This option makes curl pass the data to the server using the 28 content-type application/x-www-form-urlencoded. Compared to --form. 29 30 --data-raw is almost the same but does not have a special interpretation of 31 the @ character. To post data purely binary, you should instead use the 32 --data-binary option. To URL-encode the value of a form field you may use 33 --data-urlencode. 34 35 If any of these options is used more than once on the same command line, the 36 data pieces specified are merged with a separating &-symbol. Thus, using 37 '-d name=daniel -d skill=lousy' would generate a post chunk that looks like 38 'name=daniel&skill=lousy'. 39 40 If you start the data with the letter @, the rest should be a filename to read 41 the data from, or - if you want curl to read the data from stdin. Posting data 42 from a file named 'foobar' would thus be done with --data @foobar. When --data 43 is told to read from a file like that, carriage returns, newlines and null 44 bytes are stripped out. If you do not want the @ character to have a special 45 interpretation use --data-raw instead. 46 47 The data for this option is passed on to the server exactly as provided on the 48 command line. curl does not convert, change or improve it. It is up to the 49 user to provide the data in the correct form.