{"id":27224903,"url":"https://github.com/oxylabs/curl-post-requests","last_synced_at":"2025-09-10T00:47:17.693Z","repository":{"id":286972725,"uuid":"900752601","full_name":"oxylabs/curl-post-requests","owner":"oxylabs","description":"Learn how to send POST requests with cURL.","archived":false,"fork":false,"pushed_at":"2025-06-26T08:22:48.000Z","size":11,"stargazers_count":141,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-06-26T09:30:43.272Z","etag":null,"topics":["curl","curl-library","post","post-requests","scraping","web-scraping"],"latest_commit_sha":null,"homepage":"","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/oxylabs.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":"2024-12-09T12:08:39.000Z","updated_at":"2025-06-26T08:22:51.000Z","dependencies_parsed_at":"2025-04-09T09:47:04.338Z","dependency_job_id":null,"html_url":"https://github.com/oxylabs/curl-post-requests","commit_stats":null,"previous_names":["oxylabs/curl-post-requests"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/oxylabs/curl-post-requests","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-post-requests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-post-requests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-post-requests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-post-requests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oxylabs","download_url":"https://codeload.github.com/oxylabs/curl-post-requests/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oxylabs%2Fcurl-post-requests/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274390719,"owners_count":25276408,"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","status":"online","status_checked_at":"2025-09-09T02:00:10.223Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","curl-library","post","post-requests","scraping","web-scraping"],"created_at":"2025-04-10T10:56:38.047Z","updated_at":"2025-09-10T00:47:17.682Z","avatar_url":"https://github.com/oxylabs.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Oxylabs promo code](https://raw.githubusercontent.com/oxylabs/product-integrations/refs/heads/master/Affiliate-Universal-1090x275.png)](https://oxylabs.io/pages/gitoxy?utm_source=877\u0026utm_medium=affiliate\u0026groupid=877\u0026utm_content=curl-post-requests-github\u0026transaction_id=102f49063ab94276ae8f116d224b67)\n\n[![](https://dcbadge.vercel.app/api/server/eWsVUJrnG5)](https://discord.gg/Pds3gBmKMH)\n\n# How to Send Post Requests With cURL\n\n- [How to Send Post Requests With cURL](#how-to-send-post-requests-with-curl)\n  * [Sending POST requests](#sending-post-requests)\n  * [Specifying the Content-Type](#specifying-the-content-type)\n  * [Posting JSON](#posting-json)\n  * [Posting XML](#posting-xml)\n  * [Sending a file or multiple files via POST](#sending-a-file-or-multiple-files-via-post)\n  * [Sending authentication credentials](#sending-authentication-credentials)\n\ncURL is a powerful command-line tool for transferring data over various network protocols, including HTTP, HTTPS, FTP, and more. Since POST is a request method of HTTP \u0026 HTTPS protocols, cURL makes sending POST requests a one-line command that you can [run in your terminal](https://oxylabs.io/resources/integrations/terminal) easily. \n\nFind the [full article](https://oxylabs.io/blog/curl-post-requests) on our website.\n\n## Sending POST requests\n\nFirst, install cURL if you haven’t installed it already. You can find the installation instructions in our [How to Use cURL With Proxy](https://oxylabs.io/blog/curl-with-proxy) blog post.\n\nThe basic syntax for sending a POST request using cURL is as below:\n\n```\ncurl -X POST -d \"Hello\" https://example.com/api\n```\n\nNotice the ```-X``` flag followed by ```POST```, it tells cURL to make a request using the HTTP protocol’s POST method, and the ```-d``` flag sets request data as ```Hello``` and sends it to the website https://example.com/api. The ```-X``` flag is the short form of the command line option ```--request```. \n\n## Specifying the Content-Type\n\nLike any HTTP request, POST requests created using cURL can also have custom headers. For specifying the ```Content-Type``` header, you’ll have to set it using the header flag. \n\n```\ncurl -X POST -H \"Content-Type: text/plain\" -d \"Hello\" https://example.com/api\n```\n\nIn the above command, there’s an additional ```-H``` flag which lets users [send custom HTTP request headers via cURL](https://oxylabs.io/blog/curl-send-headers). In this case, by specifying the ```Content-Type``` header as ```text/plain``` you’re letting the web server know that the request body data is in TEXT format. \n\n## Posting JSON\n\nIt’s also possible to send JSON data in the request body. All you need to do is set the appropriate ```Content-Type``` header and pass the JSON data with the ```-d``` flag. cURL will make a POST request with the JSON data specified in the argument.\n\n```\ncurl -X POST -H \"Content-Type: application/json\" -d '{\"key\":\"value\"}' https://example.com/api\n```\n\nIf you need a straightforward way to create a JSON code from a cURL command, use this [cURL to JSON converter](https://oxylabs.io/tools/curl-converter/json).\n\n## Posting XML\n\nSimilar to JSON, you can also send XML in the request body. You’ll have to make changes to the request header and set it to ```application/xml```.\n\n```\ncurl -X POST -H \"Content-Type: application/xml\" -d '\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\u003croot\u003e\u003cname\u003eJohn Doe\u003c/name\u003e\u003cage\u003e30\u003c/age\u003e\u003c/root\u003e' https://example.com/api\n```\n\n## Sending a file or multiple files via POST\n\nTo send a file via cURL POST, you’ll have to use the ```-F``` flag. Pay attention to the capitalization of the letter “F”. All of the cURL flags or command line options are case-sensitive.\n\n```\ncurl -X POST -F \"file=@/path/to/img.png\" https://example.com/api/upload\n```\n\nAs you can see, the above command is uploading an image file. Right after the ```-F``` the file path of the image was given. You can also use multiple ```-F``` flags to send multiple files to the server as below:\n\n```\ncurl -X POST -F \"file=@/path/to/img1.png\" -F \"file=@/path/to/img2.png\" https://example.com/api/upload\n```\n\n## Sending authentication credentials\n\nYou can use the ```-u``` flag or the ```--user``` option to specify the username \u0026 password for basic authentication. cURL will automatically create the Authorization header based on your input. \n\n```\ncurl -u username:password https://example.com/login\n```\n\nYou’ll have to replace ```username``` and ```password``` with the actual authentication credentials. Also, don’t forget to replace the example URL with your own.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fcurl-post-requests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foxylabs%2Fcurl-post-requests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foxylabs%2Fcurl-post-requests/lists"}