{"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-02-26T10:31:02","modified_gmt":"2026-02-26T10:31:02","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","plain":"How to use cURL to send POST requests"},"content":{"rendered":"\n<p>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>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>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>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>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>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>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>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>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>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>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>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>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>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>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>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>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>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":"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.","protected":false,"plain":"If you're working with APIs, knowing how to send POST requests using cURL is important. Learn to send JSON, XML, form data, and files."},"author":1,"featured_media":79,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"meta_title":"","meta_description":"","footnotes":""},"categories":[1],"tags":[3],"class_list":{"0":"post-74","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-uncategorized","8":"tag-tutorials"},"featured_media_src_url":"https:\/\/wordpress-foccwcs4gooocs44ogwkggo0.thunderproxy.com\/wp-content\/uploads\/2025\/07\/pexels-fotios-photos-16129724-1024x768.jpg","tag_slugs":["tutorials"],"headings":[],"referenced_products":[],"meta_title":"","meta_description":"","_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}]}}