{"id":74,"date":"2025-07-06T09:15:37","date_gmt":"2025-07-06T09:15:37","guid":{"rendered":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/?p=74"},"modified":"2026-06-23T20:11:26","modified_gmt":"2026-06-23T20:11:26","slug":"how-to-use-curl-to-send-post-requests","status":"publish","type":"post","link":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/2025\/07\/06\/how-to-use-curl-to-send-post-requests\/","title":{"rendered":"How to use cURL to send POST requests"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">If you&#8217;re a developer working with APIs, learning how to send POST requests using cURL is a mandatory thing. It is one of the most easiest ways to test endpoints, upload data or interact with servers, all from your terminal.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this post, we will show you how to send POST requests using cURL, how to send JSON, XML, files, form data.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Is cURL Installed?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most systems already have cURL. To check if yours does, open a terminal and run the command below:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl --version<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If it\u2019s not installed, download it from&nbsp;<a class=\"\" href=\"https:\/\/curl.se\/\">curl.se<\/a>. Windows users may need Git Bash or WSL to get the best results.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: A Simple POST Request<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Here is a basic example of a POST request using cURL:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -X POST -d \"Hello\" https:\/\/example.com\/api<br><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>-X POST<\/code>&nbsp;= HTTP method<\/li>\n\n\n\n<li><code>-d<\/code>&nbsp;= data you&#8217;re sending in the body<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Add Content-Type Headers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To inform the server what kind of data you are sending, make sure to include a&nbsp;<code>Content-Type<\/code>&nbsp;header:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For plain text:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -X POST -H \"Content-Type: text\/plain\" -d \"Hello\" https:\/\/example.com\/api<br><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">For JSON:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -X POST -H \"Content-Type: application\/json\" \\<br>  -d '{\"name\":\"Alice\",\"age\":30}' https:\/\/example.com\/api<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Use single quotes to wrap JSON so your terminal doesn&#8217;t get confused by inner double quotes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Send XML Payloads<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If the API expects XML:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -X POST -H \"Content-Type: application\/xml\" \\<br>  -d '&lt;?xml version=\"1.0\"?&gt;&lt;user&gt;&lt;name&gt;Alice&lt;\/name&gt;&lt;\/user&gt;' \\<br>  https:\/\/example.com\/api<br><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Upload Files with&nbsp;<code>-F<\/code><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To upload files (like images, documents, or logs):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -X POST -F \"file=@\/path\/to\/file.jpg\" https:\/\/example.com\/upload<br><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Upload multiple files:<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -X POST \\<br>  -F \"image1=@\/path\/to\/one.jpg\" \\<br>  -F \"image2=@\/path\/to\/two.jpg\" \\<br>  https:\/\/example.com\/upload<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">cURL automatically handles&nbsp;<code>multipart\/form-data<\/code>&nbsp;for you.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Send Form Data<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For classic form-style submissions (like logging in or submitting a contact form):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -X POST -d \"username=test&amp;password=1234\" https:\/\/example.com\/login<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also pass multiple form fields with repeated&nbsp;<code>-d<\/code>&nbsp;flags or combine them into one string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Add Basic Authentication<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If the endpoint requires login credentials, use&nbsp;<code>-u<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -u username:password https:\/\/example.com\/secure<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This adds an&nbsp;<code>Authorisation<\/code>&nbsp;header automatically using Base64 encoding.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Using cURL with Residential Proxies<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you&#8217;re testing geo-targeted endpoints or want extra privacy, you can use cURL with a proxy like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>curl -x http:\/\/proxyuser:proxypass@gw.thunderproxy.net:5959 \\<br>  -X POST -d '{\"action\":\"test\"}' https:\/\/example.com\/api<br><\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">At\u00a0<a href=\"https:\/\/thunderproxy.com\/\" class=\"\">Thunderproxy.com<\/a>, we provide <a href=\"https:\/\/www.thunderproxy.com\/en\/products\/proxies\/residential-proxies\/\">residential proxies<\/a> that work perfect with cURL. This is helpful when testing websites from different locations or when you need to bypass rate limits.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final Thoughts<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">cURL is a tool for developers, system administrators and testers. It\u2019s fast and efficient &#8211; whether you are sending JSON, uploading files, or logging into protected endpoints.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once you learn the basic flags (<code>-X<\/code>,&nbsp;<code>-d<\/code>,&nbsp;<code>-H<\/code>,&nbsp;<code>-F<\/code>,&nbsp;<code>-u<\/code>), you\u2019ll be comfortable to create any kind of HTTP request in seconds.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you&#8217;re working with APIs, knowing how to send POST requests using cURL is important. Learn to send JSON, XML, form data, and files.<\/p>\n","protected":false},"author":1,"featured_media":79,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"meta_title":"How to Send POST Requests with cURL","meta_description":"Send POST requests with cURL for API work. Examples for JSON, XML, form data, and file uploads with practical command-line snippets.","plan_title":"","referenced_products":[],"footnotes":""},"categories":[1],"tags":[3],"class_list":["post-74","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized","tag-tutorials"],"tag_slugs":["tutorials"],"meta_title":"How to Send POST Requests with cURL","meta_description":"Send POST requests with cURL for API work. Examples for JSON, XML, form data, and file uploads with practical command-line snippets.","referenced_products":[],"plan_title":"","headings":[{"level":2,"text":"Step 1: Is cURL Installed?","id":"step-1-is-curl-installed","slug":"step-1-is-curl-installed"},{"level":2,"text":"Step 2: A Simple POST Request","id":"step-2-a-simple-post-request","slug":"step-2-a-simple-post-request"},{"level":2,"text":"Step 3: Add Content-Type Headers","id":"step-3-add-content-type-headers","slug":"step-3-add-content-type-headers"},{"level":3,"text":"For plain text:","id":"for-plain-text","slug":"for-plain-text"},{"level":3,"text":"For JSON:","id":"for-json","slug":"for-json"},{"level":2,"text":"Step 4: Send XML Payloads","id":"step-4-send-xml-payloads","slug":"step-4-send-xml-payloads"},{"level":2,"text":"Step 5: Upload Files with&nbsp;-F","id":"step-5-upload-files-with-f","slug":"step-5-upload-files-with-f"},{"level":3,"text":"Upload multiple files:","id":"upload-multiple-files","slug":"upload-multiple-files"},{"level":2,"text":"Step 6: Send Form Data","id":"step-6-send-form-data","slug":"step-6-send-form-data"},{"level":2,"text":"Step 7: Add Basic Authentication","id":"step-7-add-basic-authentication","slug":"step-7-add-basic-authentication"},{"level":2,"text":"Using cURL with Residential Proxies","id":"using-curl-with-residential-proxies","slug":"using-curl-with-residential-proxies"},{"level":2,"text":"Final Thoughts","id":"final-thoughts","slug":"final-thoughts"}],"lang":"en","translations":{"en":74,"ru":387,"tr":388,"de":389,"es":390},"pll_sync_post":[],"featured_media_src_url":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/wp-content\/uploads\/2025\/07\/pexels-fotios-photos-16129724-1024x768.jpg","_links":{"self":[{"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":9,"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":237,"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/posts\/74\/revisions\/237"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/media\/79"}],"wp:attachment":[{"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/index.php\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}