Logo

Programming-Idioms

  • Python
  • Ruby

Idiom #174 Make HTTP POST request

Make a HTTP request with method POST to the URL u

require "net/http"
Net::HTTP.post(u, content)
from urllib import request, parse
data = parse.urlencode(<your data dict>).encode()
req =  request.Request(u, data=data, method="POST")
resp = request.urlopen(req)

Explicit use of the "method" parameter, because "GET" is used when "data" is None
using System.Net.Http;
new HttpClient().PostAsync(u, content);

New implementation...
< >
programming-idioms.org