These curl recipes show you how to send POST requests with curl. By default, curl sends GET requests. To make it send POST requests, use the -X POST command line argument. To add POST data to the request, use the -d argument. To change the Content-Type header that tells the web server what type of data you're sending, use the -H argument.

- The cURL command-line utility comes installed in most Unix Like operating systems, including Linux and Mac OS. But, the cURL command is not available on Microsoft Windows by default. To get cURL for Windows 10, we will use git bash shell which provides useful unix command line tools for Windows. This is the easiest way to install cURL on.
- Go to curl Download Wizard Select curl executable Select Win32 or Win64 Then select package for it (Eg generic/cygwin) as per your requirement Then you will have to select version. You can select unspecified. This will directly take you to download link which on click will give you popup to.
- #Linux: export GITTRACEPACKET=1 export GITTRACE=1 export GITCURLVERBOSE=1 #Windows set GITTRACEPACKET=1 set GITTRACE=1 set GITCURLVERBOSE=1 In return there was the 'Proxy-Authorization' as the git server was spot should not go through the proxy. But the real problem was the size of the files defined by the proxy rules.
(P)Bookmarks.dev - Open source Bookmarks and Code Snippets Manager for Developers & Co. See our How To guides to help you get started. Public Bookmarks Repo on Github -
If you want to quickly test your REST api from the command line, you can use curl. In this post I will present how to execute GET, POST, PUT, HEAD, DELETE HTTP Requests against a REST API. For the purpose of this blog post I will be using the REST api that supports www.bookmarks.dev. The API is documented with OpenAPI and available for testing in the browser at https://www.bookmarks.dev/api/docs/.
- Introduction
- CRUD Operations on Bookmarks.dev API
Introduction
Cmd Curl Post
In the first part of the blog post I will do a brief introduction to curl and what it can do (HTTP requests with options). In the second part I will show examples with different HTTP operations from bookmarks.dev-api.
What is curl?
Curl is a command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, HTTP/2, cookies, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos…), file transfer resume, proxy tunneling and more.
As mentioned, I will be using curl to simulate HEAD, GET, POST, PUT and DELETE request calls against a REST API.
HEAD requests
If you want to check if a resource is serviceable, what kind of headers it provides and other useful meta-information written in response headers, without having to transport the entire content, you can make a HEAD request.
Let’s say I want to see what I would GET when requesting latest public bookmarks. I would issue the following HEAD request with curl:
Request
OR
Curl options
-Ior--head- fetch the headers only-i, --include- include the HTTP response headers in the output-X, --request- specify a custom request method to use when communicating with the HTTP server (GET, PUT, DELETE&)
Response
Note the following headers
Access-Control-Allow-Headers: Content-Type, Authorization, LocationAccess-Control-Allow-Methods: POST, GET, PUT, PATCH, DELETE, OPTIONSAccess-Control-Allow-Origin: *
in the response.
They’ve been added to support Cross-Origing Resource Sharing (CORS).
GET request
Executing curl with no parameters on a URL (resource) will execute a GET.
Request
which is equivalent with
Response
Note the use of accept: application/json
Curl options
-H, --header: customer header to pass to the server
If you want to have it displayed prettier I suggest you use a tool like jq:
Request
Response
If you don’t want the progress meter (first part) shown, you can silent curl:
Request
How To Run Curls In Cmd
Response
Curl options
-s, --silent: silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.
An alternative to jq is to use Python if you have it on your machine:
Curl request with multiple headers
All the responses from the api of bookmarks.dev are gzipped.We could ask for the gzipped variant by issuing the following request:
Request
Curl options
-v, --verbose: the opposite of--silent, make the operation more talkative
To achieve that you need to simply add another-H option with the corresponding value. In this case you would get some unreadable characters in the content, if you do not redirect the response to a file:

Response
CRUD Operations on Bookmarks.dev API
Those were some basic curl HTTP calls with a few options. Now we will combine them and show examples against a productionready API. For the examples I will use the API running on localhost. It is really easy to setup with Docker-compose ifyou follow the instructions from the Readme file.
The API is protected with Keycloak and bearer token. A way to obtain a bearer token in Keycloak is to enable Direct Access Grants for the client - this corresponds to the Resource Owner Password Credentialsin the OAuth2 Specification. Thus the user’s credentials are sent within form parameters. Of course we can do that with curl too:
Request
The the username and password are from the initial set up.
The response looks something like the following:
Cmd Curl Is Not Recognized
With jq is really easy to extract just the access_token:
Request
Response
Curl options
-d, --data: (HTTP) 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 content-typeapplication/x-www-form-urlencoded.
Create bookmark - POST
Request
How To Run Curl Command
Note the Bearer token is reduced here (Bearer eyJhbGciOiJ....) and in the following examples for brevity
Response
Note the location header - it contains the URL of the new created resource
Read created resource - GET
We will read the previously created bookmark by issuing an GET request on the url from the location header
Response
Update created resource - PUT

Request
Response

Delete created resource - DELETE
Request
Response
Note the 204 OK Status showing that everything worked as expected.
Trying to execute the deletion again will result in an 404 resource NOT_FOUND status:
Response
The stacktrace is shown because we are in dev modus
Conclusion
I am just scratching the surface in this blog post. Check out the curl docs for furthercapabilities.
