curl
curl
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. curl can transfer multiple file at once.
You'll see the following cURL flags in the examples in the Zendesk REST API
docs.
-H
Specifies any extra header content to include in the HTTP request. API requests
that submit data to our servers typically include the data's content type.
Example:
-u
Specifies the user name and password to use for server authentication. The user
name and password are separated by a colon.
Example: -u [email protected]:mypassword
-v
-X
Specifies the request method to use when communicating with the HTTP server.
Example: PUT or POST.
Note: GET is the default method so you don't need to specify it.
Example: -X PUT
-G --data-urlencode
Used for API endpoints that send data in a query string, such as the Search API.
The --data-urlencode option url-encodes the query string. The -G flag specifies
that the url-encoded data is for a GET request rather than a POST request.
For example, suppose you want to run the following search using the List Search
Results endpoint:
.../api/v2/search.json?query=type:ticket status:open
curl "https://{subdomain}.zendesk.com/api/v2/search.json" \
-G --data-urlencode "query=type:ticket status:open" \
-v -u {email_address}:{password}
curl https://www.geeksforgeeks.org
This should display the content of the URL on the terminal. The URL syntax is protocol
dependent and multiple URLs can be written as sets like:
curl http://site.{one, two, three}.com
URLs with numeric sequence series can be written as:
curl ftp://ftp.example.com/file[1-20].jpeg
Progress Meter: curl displays a progress meter during use to indicate the transfer rate,
amount of data transferred, time left etc.
curl -# -o ftp://ftp.example.com/file.zip
curl --silent ftp://ftp.example.com/file.zip
If you like a progress bar instead of meter, you can use the -# option as in the example
above, or –silent if you want to disable it completely.
Example:
Options:
-o : saves the downloaded file on the local machine with the name provided in the
parameters.
Syntax:
curl -o [file_name] [URL...]
Example:
curl -o hello.zip ftp://speedtest.tele2.net/1MB.zip
Output:
The above example downloads the file from FTP server and saves it with the
name hello.zip.
-O : This option downloads the file and saves it with the same name as in the URL.
Syntax:
curl -O [URL...]
Example:
curl -O ftp://speedtest.tele2.net/1MB.zip
Output:
-C – : This option resumes download which has been stopped due to some
reason. This is useful when downloading large files and was interrupted.
Syntax:
curl -C - [URL...]
Example:
curl -C - -O ftp://speedtest.tele2.net/1MB.zip
–limit-rate : This option limits the upper bound of the rate of data transfer and
keeps it around the given value in bytes.
Syntax:
curl --limit-rate [value] [URL]
Example:
curl --limit-rate 1000K -O ftp://speedtest.tele2.net/1MB.zip
Output:
Note: There are a number of other options provided by cURL which can be checked on
the man page. The Libcurl library has been ported into various programming languages.
It’s advisable to visit the individual project site for documentation.