2023-01-02 20:51:48 +08:00
|
|
|
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2022-06-14 06:12:03 +08:00
|
|
|
SPDX-License-Identifier: curl
|
2016-11-16 06:44:58 +08:00
|
|
|
Long: data
|
|
|
|
Short: d
|
|
|
|
Arg: <data>
|
|
|
|
Help: HTTP POST data
|
2020-04-14 17:19:12 +08:00
|
|
|
Protocols: HTTP MQTT
|
2016-11-16 06:44:58 +08:00
|
|
|
See-also: data-binary data-urlencode data-raw
|
2018-05-28 20:17:51 +08:00
|
|
|
Mutexed: form head upload-file
|
2020-07-13 20:15:04 +08:00
|
|
|
Category: important http post upload
|
2021-08-31 22:37:14 +08:00
|
|
|
Example: -d "name=curl" $URL
|
|
|
|
Example: -d "name=curl" -d "tool=cmdline" $URL
|
|
|
|
Example: -d @filename $URL
|
2021-09-28 17:50:07 +08:00
|
|
|
Added: 4.0
|
2022-10-18 16:39:43 +08:00
|
|
|
Multi: append
|
2016-11-16 06:44:58 +08:00
|
|
|
---
|
|
|
|
Sends the specified data in a POST request to the HTTP server, in the same way
|
|
|
|
that a browser does when a user has filled in an HTML form and presses the
|
|
|
|
submit button. This will cause curl to pass the data to the server using the
|
2021-11-26 15:46:59 +08:00
|
|
|
content-type application/x-www-form-urlencoded. Compare to --form.
|
2016-11-16 06:44:58 +08:00
|
|
|
|
|
|
|
--data-raw is almost the same but does not have a special interpretation of
|
|
|
|
the @ character. To post data purely binary, you should instead use the
|
2021-11-26 15:46:59 +08:00
|
|
|
--data-binary option. To URL-encode the value of a form field you may use
|
2016-11-16 06:44:58 +08:00
|
|
|
--data-urlencode.
|
|
|
|
|
|
|
|
If any of these options is used more than once on the same command line, the
|
2021-11-26 15:46:59 +08:00
|
|
|
data pieces specified will be merged with a separating &-symbol. Thus, using
|
2022-08-23 19:42:49 +08:00
|
|
|
'-d name=daniel -d skill=lousy' would generate a post chunk that looks like
|
|
|
|
'name=daniel&skill=lousy'.
|
2016-11-16 06:44:58 +08:00
|
|
|
|
|
|
|
If you start the data with the letter @, the rest should be a file name to
|
2020-01-21 15:39:47 +08:00
|
|
|
read the data from, or - if you want curl to read the data from stdin. Posting
|
2022-08-23 19:42:49 +08:00
|
|
|
data from a file named 'foobar' would thus be done with --data @foobar. When
|
2020-01-21 15:39:47 +08:00
|
|
|
--data is told to read from a file like that, carriage returns and newlines
|
2021-10-31 23:34:44 +08:00
|
|
|
will be stripped out. If you do not want the @ character to have a special
|
2020-01-21 15:39:47 +08:00
|
|
|
interpretation use --data-raw instead.
|
2023-03-23 18:48:45 +08:00
|
|
|
|
|
|
|
The data for this option is passed on to the server exactly as provided on the
|
|
|
|
command line. curl will not convert it, change it or improve it. It is up to
|
|
|
|
the user to provide the data in the correct form.
|