{"id":26570727,"url":"https://github.com/luminati-io/curl-post-request","last_synced_at":"2026-04-10T01:13:19.649Z","repository":{"id":283783972,"uuid":"927081388","full_name":"luminati-io/curl-post-request","owner":"luminati-io","description":"Send cURL POST requests, set headers, send data, and handle authentication for APIs and web scraping with this comprehensive guide.","archived":false,"fork":false,"pushed_at":"2025-02-04T11:26:49.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-03-22T07:02:01.375Z","etag":null,"topics":["curl","http","linux","macos","post","proxy-server","web-scraping","windows"],"latest_commit_sha":null,"homepage":"https://brightdata.com/blog/how-tos/curl-post-request-guide","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luminati-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-04T11:24:12.000Z","updated_at":"2025-02-04T11:33:07.000Z","dependencies_parsed_at":"2025-03-22T07:02:04.222Z","dependency_job_id":"af9dbf48-905f-4346-aa04-fbd99729e1b6","html_url":"https://github.com/luminati-io/curl-post-request","commit_stats":null,"previous_names":["luminati-io/curl-post-request"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fcurl-post-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fcurl-post-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fcurl-post-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luminati-io%2Fcurl-post-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luminati-io","download_url":"https://codeload.github.com/luminati-io/curl-post-request/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245026414,"owners_count":20549129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["curl","http","linux","macos","post","proxy-server","web-scraping","windows"],"created_at":"2025-03-22T22:19:08.551Z","updated_at":"2025-12-30T23:43:00.710Z","avatar_url":"https://github.com/luminati-io.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sending cURL POST Requests\n\n[![Promo](https://github.com/luminati-io/LinkedIn-Scraper/raw/main/Proxies%20and%20scrapers%20GitHub%20bonus%20banner.png)](https://brightdata.com/) \n\n[cURL](https://brightdata.com/blog/web-data/what-is-curl#:~:text=curl%2C%20short%20for%20%E2%80%9Cclient%20URL,%2C%20cars%2C%20and%20medical%20devices.) is a command line tool for transferring data, most commonly by sending HTTP requests. You can use it to send requests to REST APIs and scrape websites. This guide explains what a cURL POST request is, how to send it, and what command line arguments you can use while doing that.\n\n- [What Is a POST Request](#what-is-a-post-request)\n- [Installing cURL](#installing-curl)\n- [Making a POST Request](#making-a-post-request)\n  - [Specifying the POST Method](#specifying-the-post-method)\n  - [Setting the Content-Type](#setting-the-content-type)\n  - [Sending Data](#sending-data)\n  - [Uploading Files](#uploading-files)\n  - [Sending Credentials](#sending-credentials)\n- [Important cURL Arguments](#important-curl-arguments)\n- [Conclusion](#conclusion)\n\n## What Is a POST Request\n\nA POST request is a widely used HTTP method for transmitting data to a server.\n\nUnlike GET requests, where data is appended to the URL, a POST request includes the transmitted data in the request body. This approach enhances privacy and allows for the transfer of more data, bypassing the URL length limitations imposed by browsers.\n\nPOST requests are commonly utilized for submitting forms, uploading files, and sending JSON data to APIs. Unlike GET requests, they are generally not cached, and the data remains hidden from browser history since it is contained within the request body.\n\n## Installing cURL\n\nBefore you trying using cURL, let's verify if it's installed on your system. Run this command in the terminal:\n\n```bash\ncurl --version\n```\n\nIf you see an error message saying that the command is not available, you need to install cURL.\n\nOn Windows 11 with WinGet:\n\n```bash\nwinget install curl.curl\n```\n\nOn Windows with Chocolatey:\n\n```bash\nchoco install curl\n```\n\nOn macOS with Homebrew:\n\n```bash\nbrew install curl\n```\n\nOn Ubuntu/Debian Linux:\n\n```bash\napt-get install curl\n```\n\nOn Red Hat Enterprise Linux, CentOS, and Fedora Linux:\n\n```bash\nyum install curl\n```\n\nIf you run another flavor of Linux, please use its native package manager (e.g. `zypper` on openSUSE or `pacman` on Arch).\n\n## Making a POST Request\n\n### Specifying the POST Method\n\nYou need to specify the HTTP method you want to perform when making HTTP requests. The most common methods are GET, POST, PUT, and DELETE. To specify the method, use the `-X` (or `--request`) command line flag.\n\nFor example, to send a POST request to `https://httpbin.org/anything`, do this:\n\n```bash\ncurl -X POST https://httpbin.org/anything\n```\n\n[httpbin.org](httpbin.org) echoes the request body and headers in the response. Your response should look like this:\n\n```json\n{\n  \"args\": {},\n  \"data\": \"\",\n  \"files\": {},\n  \"form\": {},\n  \"headers\": {\n    \"Accept\": \"*/*\",\n    \"Host\": \"httpbin.org\",\n    \"User-Agent\": \"curl/8.1.2\",\n    \"X-Amzn-Trace-Id\": \"Root=1-11111111-111111111111111111111111\"\n  },\n  \"json\": null,\n  \"method\": \"POST\",\n  \"origin\": \"0.0.0.0\",\n  \"url\": \"https://httpbin.org/anything\"\n}\n```\n\n### Setting the Content-Type\n\nWhen you make a POST request, define the content type in the request body to ensure the server correctly interprets the data. This is done by setting the `Content-Type` header with the appropriate MIME type.\n\nFor example, if you're sending JSON in the request body, you need to tell the web server to expect JSON content by setting the `Content-Type` header to `application/json`. To do that, use the `-H` (or `--header`) flag:\n\n```bash\ncurl -X POST -H 'Content-Type: application/json' -d '{}' https://httpbin.org/anything\n```\n\n### Sending Data\n\nThe `-d` (or `--data`) flag lets you specify the data to send in the request body. You can use the flag to pass any string of values surrounded by quotations, like this:\n\n```bash\ncurl -X POST -H 'Content-Type: application/json' -d '{\n    \"FirstName\": \"Joe\", \n    \"LastName\": \"Soap\" \n}' https://httpbin.org/anything\n```\n\nIf you have a file with data that you want cURL to send in the body, specify the file name prefixed with the `@` character:\n\n```bash\ncurl -X POST -H 'Content-Type: application/json' -d @body.json https://httpbin.org/anything\n```\n\n#### Sending JSON Data\n\nWhen sending JSON data, set both the `Content-Type` and `Accept` headers to `application/json`:\n\n```bash\ncurl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{\n    \"FirstName\": \"Joe\",\n    \"LastName\": \"Soap\"\n}' https://httpbin.org/anything\n```\n\ncURL offers a `--json` flag (available since version 7.82) that sets these headers automatically:\n\n```bash\ncurl -X POST --json '{\n    \"FirstName\": \"Joe\",\n    \"LastName\": \"Soap\"\n}' https://httpbin.org/anything\n```\n\n#### Sending XML Data\n\nTo send XML data, set the appropriate content headers and provide XML in the request body:\n\n```bash\ncurl -X POST -H 'Content-Type: application/xml' -H 'Accept: application/xml' -d '\u003cPerson\u003e\n    \u003cFirstName\u003eJoe\u003c/FirstName\u003e\n    \u003cLastName\u003eSoap\u003c/LastName\u003e\n\u003c/Person\u003e' https://httpbin.org/anything\n```\n\n#### Sending FormData\n\nFor form submissions, use the `-F` (or `--form`) flag with field name and value pairs:\n\n```bash\ncurl -X POST -F FirstName=Joe -F LastName=Soap https://httpbin.org/anything\n```\n\n### Uploading Files\n\nTo upload files using FormData, prefix the file path with `@`:\n\n```bash\ncurl -X POST -F File=@Contract.pdf https://httpbin.org/anything\n```\n\n### Sending Credentials\n\nFor basic authentication, use the `-u` (or `--user`) flag with username and password:\n\n```bash\ncurl -X POST -u 'admin:password123' --json '{\n    \"FirstName\": \"Joe\",\n    \"LastName\": \"Soap\"\n}' https://httpbin.org/anything\n```\n\n## Important cURL Arguments\n\n| Argument | Full Option | Short Description |\n|----------|-------------|-------------------|\n| -X | --request | Specify HTTP method used |\n| -d | --data | Send request body data |\n| -F | --form | Send form-based data |\n| -H | --header | Set request header fields |\n| -i | --include | Include response headers output |\n| -v | --verbose | Show extra debug details |\n| -L | --location | Follow redirects automatically |\n| -o | --output | Write response to file |\n| -O | --remote-name | Save as remote filename |\n| -C | --continue-at | Resume transfer from offset |\n| -u | --user | Set basic auth credentials |\n| -x | --proxy | Use specified proxy server |\n| -k | --insecure | Skip SSL certificate checks |\n| -I | --head | Fetch headers only (HEAD) |\n| -b | --cookie | Send stored cookies data |\n| -c | --cookie-jar | Write cookies to file |\n| -e | --referer | Set Referer header |\n| -A | --user-agent | Set custom User-Agent |\n| -m | --max-time | Maximum request time limit |\n| --max-filesize | (no short form) | Limit downloaded file size |\n| -z | --time-cond | Download if modified since |\n| --compressed | (no short form) | Request compressed response |\n| --data-urlencode | (no short form) | URL-encode data fields |\n| --interface | (no short form) | Bind to specific interface |\n| -w | --write-out | Print custom response info |\n| -r | --range | Request specific byte range |\n| -s | --silent | Suppress progress output |\n| -f | --fail | Fail silently on errors |\n| -g | --globoff | Disable bracket expansions |\n| --http1.0 | (no short form) | Use HTTP/1.0 protocol |\n| --http1.1 | (no short form) | Use HTTP/1.1 protocol |\n| --http2 | (no short form) | Use HTTP/2 protocol |\n| --http3 | (no short form) | Use HTTP/3 protocol |\n| -Z | --parallel | Send requests simultaneously |\n| --proxy-user | (no short form) | Proxy authentication credentials |\n| --digest | (no short form) | Use HTTP Digest auth |\n| --ntlm | (no short form) | Use HTTP NTLM auth |\n| --negotiate | (no short form) | Use SPNEGO/Kerberos auth |\n\n## Conclusion\n\ncURL offers many additional features worth exploring, such as using variables, sending cookies, and working with proxies. To avoid exposing your public IP address when making automated HTTP requests, consider using [Bright Data's proxy services](https://brightdata.com/proxy-types) to mask your IP address. Create a free Bright Data account today to test our proxies and scraping solutions!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminati-io%2Fcurl-post-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluminati-io%2Fcurl-post-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluminati-io%2Fcurl-post-request/lists"}