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