restful api postgresql code example
Example: call rest api from postgresql
CREATE OR REPLACE FUNCTION restful.put(auri character varying, ajson_text text)
RETURNS text
LANGUAGE plperlu
SECURITY DEFINER
AS $function$
use REST::Client;
use Encode qw(encode);
my $client = REST::Client->new();
$client->getUseragent()->proxy( 'https', 'http://some-proxy/' );
$client->addHeader('Content-Type', 'application/json');
$client->POST( $_[0], encode('UTF-8', $_[1]));
return $client->responseContent();
$function$