DevNet Associate DEVASC 200-901 Official Certification Guide by Adrian Iliesiu (z-lib.org)

(andrew) #1

-postman/introduction/.


curl


curl is an extensive command-line tool that can be
downloaded from https://curl.haxx.se. curl can be used
on just about any platform on any hardware that exists
today. Regardless of what you are running and where,
the most basic curl commands just work.


With curl, you commonly use a couple of different
command-line options:


-d: This option allows you to pass data to the remote server. You can
either embed the data in the command or pass the data using a file.
-H: This option allows you to add an HTTP header to the request.
-insecure: This option tells curl to ignore HTTPS certificate
validation.
-c: This option stores data received by the server. You can reuse this
data in subsequent commands with the -b option.
-b: This option allows you to pass cookie data.
-X: This option allows you to specify the HTTP method, which
normally defaults to GET.

Now let’s take a look at some examples of how to use
curl. Example 7-7 shows how to use curl to call a simple
GET request.


Example 7-7 Sample HTTP GET Using curl

Click here to view code image


$ curl -sD - https://postman-echo.com/get?
test=123
HTTP/1.1 200 OK
Content-Type: application/json; charset=utf-8
Date: Tue, 27 Aug 2019 04:59:34 GMT
ETag: W/"ca-42Kz98xXW2nwFREN74xZNS6JeJk"
Server: nginx
set-cookie:
sails.sid=s%3AxZUPHE3Ojk1yts3qrUFqTj_MzBQZZR5n.NrjPkNm0WplJ7%2F%2BX9O7VU
TFpKHpJySLzBytRbnlzYCw; Path=/; HttpOnly
Vary: Accept-Encoding
Content-Length: 202
Connection: keep-alive
Free download pdf