This language bar is your friend. Select your favorite languages!

Idiom #174 Make HTTP POST request

Make a HTTP request with method POST to URL u

using System.Net.Http;
new HttpClient().PostAsync(u, content);
auto response = post(u, content);
import 'package:http/http.dart';
await post(u, body: body, headers: headers);
import "net/http"
response, err := http.Post(u, contentType, body)
import "net/http"
import "net/url"
response, err := http.PostForm(u, formValues)
fetch(u, {
        method: "POST",
	body: JSON.stringify(data)
(ql:quickload :drakma)
(drakma:http-request u :method :post)
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $u); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_POST, 1);
$output = curl_exec($ch); 
with TFPHTTPClient.Create(nil) do
use LWP::UserAgent;
# Create a user agent object

my $ua = LWP::UserAgent->new;
# Create a request
my $req = HTTP::Request->new(POST => $u);
# Pass request to the user agent and get a response back
my $res = $ua->request($req);
# Check the outcome of the response
if ($res->is_success) {
    print $res->content;
else {
    print $res->status_line, "\n";
my $response = `curl -X POST $u`;
perl -Mojo -E 'my $u = ""; say p($u)->body;'
from urllib import request, parse
data = parse.urlencode(<your data dict>).encode()
req =  request.Request(u, data=data, method="POST")
resp = request.urlopen(req)
require "net/http", content)
use reqwest;
let client = reqwest::blocking::Client::new();
let resp ="")
    .body("this is the body")

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

Related idioms