The pgsql-http extension provides for complex http requests in a synchronous manner from within Postgres.