Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL -d . parameter

Tags:

curl

I have this curl command:

curl -k -d . -o SessionRequest.txt  "https://myserver.com/MyWebApi/user?companysn=1234&login=my_login&password=my_password&ApiKey=my_api_key" 

What does -d . stand for? What does it do?

like image 756
user1523271 Avatar asked Oct 10 '17 18:10

user1523271


People also ask

What are curl parameters?

Sending data to the server-d or --data parameter allows to specify data to send to the HTTP server. It simulates a form submission. Invoking cURL with this parameter will make a POST request (instead of default GET ). cURL will set Content-Type as application/x-www-form-urlencoded automatically.

What is curl option?

curl (short for "Client URL") is a command line tool that enables data transfer over various network protocols. It communicates with a web or application server by specifying a relevant URL and the data that need to be sent or received. curl is powered by libcurl, a portable client-side URL transfer library.

What is curl example?

curl is a command-line tool to transfer data to or from a server, using any of the supported protocols (HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP, or FILE). curl is powered by Libcurl. This tool is preferred for automation since it is designed to work without user interaction.

How do you use curl options?

To make an OPTIONS request with Curl, you must pass the -X OPTIONS command-line parameter to the Curl request. Browsers send OPTIONS requests when making a CORS request to another origin. The OPTIONS request does not return any data. All information is returned in the response headers.


1 Answers

Whenever your have a doubt use man.

Issue man curl and read about -d switch.

-d, --data <data>     (HTTP)  Sends  the  specified data in a POST request to the HTTP     cause curl to pass the data to the server using the content-type     -d, --data is the same as --data-ascii. --data-raw is almost the     ter.  To  post  data  purely  binary, you should instead use the     [...]      

It allows you to send ASCII data, eg.:

curl -d '{"hello": "world"}' -X POST -H "Content-Type: application/json" https://example.com 

Send a JSON string to the server.

In your example, it just send a . character as ASCII data to the server. What it does depends on the server logic and is out of the curl command scope.

This said, we can guess what a . (dot, period, full stop) might mean in computer science:

  • Dot is a placeholder for the current directory in Unix File Systems;
  • Dot is a wildcard for any character in most Regular Expression grammars;
  • Dot is the separator between labels in domain name;
  • Dot is a common separator for filename and extension;

Nota: It is considered as a bad practice to send credentials using GET parameters, avoid it if you can and read more.

like image 144
jlandercy Avatar answered Oct 04 '22 04:10

jlandercy