API’lerle ?al??an bir geli?tiriciyseniz, cURL kullanarak POST istekleri g?ndermeyi ??renmek zorunludur. U? noktalar? test etmenin, veri y?klemenin veya sunucularla etkile?im kurman?n en kolay yollar?ndan biridir ve hepsini terminalinizden yapabilirsiniz.
Bu yaz?da cURL ile POST isteklerinin nas?l g?nderilece?ini, JSON, XML, dosya ve form verilerinin nas?l iletilece?ini g?sterece?iz.
Ad?m 1: cURL Kurulu mu?
?o?u sistemde cURL zaten y?kl?d?r. Sizinkinde olup olmad???n? kontrol etmek i?in bir terminal a??n ve a?a??daki komutu ?al??t?r?n:
curl --version
If it’s not installed, download it from curl.se. Windows users may need Git Bash or WSL to get the best results.
Ad?m 2: Basit Bir POST ?ste?i
??te cURL ile bir POST iste?inin temel bir ?rne?i:
curl -X POST -d "Hello" https://example.com/api
-X POST= HTTP y?ntemi-d= g?vdede g?nderdi?iniz veri
Ad?m 3: Content-Type Ba?l?klar? Ekleyin
Sunucuya hangi t?r veriyi g?nderdi?inizi belirtmek i?in mutlaka bir Content-Type ba?l??? ekleyin:
D?z metin i?in:
curl -X POST -H "Content-Type: text/plain" -d "Hello" https://example.com/api
JSON i?in:
curl -X POST -H "Content-Type: application/json" \
-d '{"name":"Alice","age":30}' https://example.com/api
JSON’u tek t?rnak i?ine al?n; b?ylece terminaliniz i?teki ?ift t?rnaklar nedeniyle kar??maz.
Ad?m 4: XML ??eri?i G?nderme
API XML bekliyorsa:
curl -X POST -H "Content-Type: application/xml" \
-d '<?xml version="1.0"?><user><name>Alice</name></user>' \
https://example.com/api
Ad?m 5: Dosyalar? -F ile Y?kleyin
Dosya y?klemek i?in (g?rseller, belgeler veya loglar gibi):
curl -X POST -F "file=@/path/to/file.jpg" https://example.com/upload
Birden fazla dosya y?kleme:
curl -X POST \
-F "image1=@/path/to/one.jpg" \
-F "image2=@/path/to/two.jpg" \
https://example.com/upload
cURL, sizin i?in multipart/form-data i?lemini otomatik olarak y?netir.
Ad?m 6: Form Verisi G?nderme
Klasik form tarz? g?nderimler i?in (oturum a?ma veya ileti?im formu g?nderme gibi):
curl -X POST -d "username=test&password=1234" https://example.com/login
Ayr?ca tekrar eden -d bayraklar?yla birden fazla form alan? g?nderebilir veya bunlar? tek bir dizede birle?tirebilirsiniz.
Ad?m 7: Basic Authentication Ekleyin
U? nokta giri? bilgileri gerektiriyorsa -u kullan?n:
curl -u username:password https://example.com/secure
Bu, Base64 kodlamas? kullanarak otomatik olarak bir Authorisation ba?l??? ekler.
Residential Proxy’lerle cURL Kullan?m?
Co?rafi hedefli u? noktalar? test ediyorsan?z veya ekstra gizlilik istiyorsan?z, cURL’? bir proxy ile ?u ?ekilde kullanabilirsiniz:
curl -x http://proxyuser:[email protected]:5959 \
-X POST -d '{"action":"test"}' https://example.com/api
At Thunderproxy.com, we provide residential proxies that work perfect with cURL. This is helpful when testing websites from different locations or when you need to bypass rate limits.
Son D???nceler
cURL is a tool for developers, system administrators and testers. It’s fast and efficient – whether you are sending JSON, uploading files, or logging into protected endpoints.
Once you learn the basic flags (-X, -d, -H, -F, -u), you’ll be comfortable to create any kind of HTTP request in seconds.