The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use these ten cURL examples to make GET and POST requests, add query parameters and headers, send JSON or files, save downloads, and diagnose failures. Replace the example domains, credentials, and filenames with values your API expects. A URL by itself makes a GET request; options such as -G, -d, -H, -F, -o, and -L change how the request is sent or handled.
Before you copy a command
Run each command in a terminal where cURL is installed. cURL is the command-line transfer tool; the examples below use its curl command-line interface. Replace api.example.com, sample values, and file paths with the endpoint and data for your application. An API may require a particular HTTP method, content type, authentication scheme, or field name, so check that endpoint’s instructions when a request is rejected.
In shell commands, a backslash at the end of a line continues the command on the next line in common Unix-like shells. In Windows Command Prompt, use a single line or adapt line continuations to that shell; PowerShell also has different quoting and continuation rules. Quoting is important: it prevents the shell from interpreting characters such as & in URLs as shell syntax.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches1. Make a basic GET request
curl https://api.example.com/users
A URL-only invocation performs a GET-style retrieval. cURL writes the response body to the terminal by default, which is convenient for small text or JSON responses. If the response is large, binary, or intended as a file, save it with an output option instead of letting the terminal display it.
2. Make a GET request with query parameters
curl -G 'https://api.example.com/users'
--data-urlencode 'role=developer'
--data-urlencode 'active=true'
-G tells cURL to put data supplied with data options into the URL query string while retaining GET semantics. --data-urlencode encodes each value for use in a URL, which is safer than manually joining parameters when values contain spaces or reserved characters. Multiple options add multiple query parameters.
Use this pattern when an endpoint expects filters or search terms in the URL, not a request body. If the server reports a missing parameter, check the exact parameter names and whether it expects repeated keys, a particular boolean spelling, or a different method.
3. Inspect response headers
curl -I https://api.example.com/health
-I requests headers without displaying a response body, useful for checking status and metadata such as content type. If you need the headers and the body together, use -i instead. To save received headers to a file, use -D headers.txt; this keeps them separate from the response body.
Header inspection is useful when verifying redirects, caching behavior, content type, or a health endpoint’s response. It does not show every detail of the connection or request; use verbose mode when diagnosing those.
4. Download a file and follow redirects
curl -L -o release.tar.gz https://downloads.example.com/latest
-o writes the response body to the filename you choose. -L follows HTTP redirects, which is often necessary for a URL such as /latest that redirects to a versioned download. Without -L, you may save the redirect response rather than the file you expected.
Rank #2
Use -O instead of -o release.tar.gz when you want cURL to use the remote filename. Check the destination path and available disk space before downloading large files; cURL overwrites an existing chosen output file.
5. Send a form-encoded POST
curl -X POST https://api.example.com/login
-d 'username=alice'
-d 'password=example-secret'
-d sends request data and cURL uses POST for this form-style request. This is a common shape for endpoints expecting form-encoded fields. The receiving endpoint must support the expected encoding and names; a JSON endpoint will generally need a JSON body and suitable content type instead.
Do not put real passwords, API keys, or other secrets in commands that may be saved in shell history, terminal logs, or process listings. For real credentials, prefer a safer secret-handling method supported by your environment and the service.
6. Send a JSON POST
curl --json '{"name":"Ada","language":"C"}'
https://api.example.com/users
--json is a concise way to send a JSON request body. For a body stored in a file, use --json @payload.json. Ensure the file contains valid JSON and that the receiving endpoint accepts the fields you provide. A syntactically valid JSON document can still fail validation if the API expects different names, types, or required fields.
7. Add headers and bearer authentication
curl https://api.example.com/me
-H 'Accept: application/json'
-H 'Authorization: Bearer REDACTED_TOKEN'
-H adds an HTTP header; repeat it for each header. Accept tells the server the response representation the client can handle, while the Authorization header carries a bearer token in this example. Replace REDACTED_TOKEN with a valid credential only in a secure context, and keep tokens out of committed scripts and logs.
Rank #3
Authentication formats vary. Some endpoints use a different Authorization scheme, an API-key header, or cURL’s documented authentication options. Match the service’s expected mechanism rather than assuming every token is a bearer token.
8. Upload a file as multipart form data
curl -F 'description=design'
-F 'file=@./design.png'
https://api.example.com/assets
-F creates multipart form fields. The @ before ./design.png tells cURL to attach the local file contents as the value of the file field; the other option supplies a regular text field. Use the field names required by the endpoint, and confirm the local file exists and is readable.
Multipart form upload differs from sending a raw file body. Choose it when the server expects form fields alongside an attachment, rather than simply streaming file bytes.
9. Upload a file directly
curl --upload-file ./build.zip https://uploads.example.com/build.zip
--upload-file sends the named local file as a direct upload request. Use it when the server expects a raw file transfer, not multipart form data. The server may require a specific method, destination URL, content type, or signed upload URL; follow those endpoint requirements. If an upload is rejected, verify the destination and permissions as well as the file path.
10. Make diagnostics and HTTP failures visible
curl -sS --fail-with-body -v
-H 'Accept: application/json'
https://api.example.com/status
-sS hides the progress meter but still prints cURL errors. -v adds connection and request diagnostics, including headers, so use it carefully: verbose output can expose sensitive headers or other details in logs. --fail-with-body makes HTTP error responses visible to automation while retaining the response body, which can contain useful API error details.
Option availability depends on the installed cURL version. If cURL says an option is unknown, check the version and the installed command’s manual page rather than assuming the same flags are available everywhere. In scripts, also check the process exit status and inspect the response body or headers appropriate to the failure.
Choosing the right cURL pattern
| Need | Pattern | Key option |
|---|---|---|
| Read an endpoint | URL-only request | GET-style retrieval |
| Pass filters in the URL | GET with encoded data | -G, --data-urlencode |
| Send form fields | Form-encoded POST | -d |
| Send a JSON document | JSON POST | --json |
| Attach fields and a file | Multipart upload | -F |
| Transfer raw file contents | Direct upload | --upload-file |
| Save a response as a file | Download | -o or -O |
| Follow redirects | Redirecting download or request | -L |
| Inspect headers or connection behavior | Header or verbose diagnostics | -I, -i, -D, -v |
Common cURL problems and fixes
The server says a parameter is missing
Check whether the endpoint expects a query parameter, form field, JSON property, or multipart field. A parameter in the wrong place may not be read even when its name is correct. For a GET query, use -G with --data-urlencode; for a JSON body, use --json.
The response is a redirect page or the download is not the expected file
Add -L if the endpoint redirects. Use -i or -D headers.txt to inspect response headers, and confirm the final URL provides the file rather than an HTML error page.
The API returns an HTTP error but the script appears to succeed
Use --fail-with-body where supported, inspect the retained response body, and check cURL’s exit status. An HTTP error response is not the same as a network-level transfer failure; automation should handle both deliberately.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11The command reports an unknown option
The installed cURL may not support that option. Check the local version and its manual page, then use a compatible documented form or update cURL through the normal method for your operating system.
Best Value
The upload fails before reaching the API
Confirm the file path is correct relative to the current directory and the process can read it. Then check whether the endpoint expects multipart form data (-F) or a direct file body (--upload-file), and whether the destination accepts the request.
The shell changes the URL or arguments
Quote URLs and values, especially those containing &, spaces, or shell metacharacters. If a multiline command fails, use the continuation syntax for your shell or put the command on one line.
Or skip the browser setup
If the task is to capture a website rather than call an API endpoint, ScreenshotNeo provides a screenshot API: one GET request with a URL returns a PNG, JPEG, WebP, or PDF. Its cURL call is:
Free tools Windows power users keep installed
One-click scans. No signup required.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options. Before capture, it accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. It also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for AI agents using Claude, Cursor, or another MCP client.
The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots. Sign up for ScreenshotNeo free to get 1,000 screenshots a month without a card.
Frequently Asked Questions
How can I save response headers without saving the body?
Use -D headers.txt; use -I when you want a headers-only request.
What should I do if --fail-with-body is not recognized?
Check the installed cURL version and its manual page for supported options.
Quick wins for a faster PC:
Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

