Skip to content
koducathome

cURL to SQL Oracle UTL_HTTP Converter

Convert curl commands to SQL code using Oracle UTL_HTTP. Paste a command and the Oracle UTL_HTTP snippet appears instantly — everything runs in your browser.

How to use this tool

Steps for using the cURL to Code.

  1. Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
  2. Paste it into Enter cURL command. The SQL Oracle UTL_HTTP code appears instantly; other SQL libraries (PostgreSQL http, SQL Server) are in the tabs above the code.
  3. Set up: Grant the database user access to the host with the append_host_ace procedure of DBMS_NETWORK_ACL_ADMIN. For HTTPS, create an Oracle wallet with the server's CA certificate and point UTL_HTTP.set_wallet at it.
  4. Run it: Run the block in SQL*Plus, SQLcl or SQL Developer; SET SERVEROUTPUT ON shows the output. Replace placeholders such as YOUR_TOKEN first, and check any notes under the editors for curl options that have no Oracle UTL_HTTP equivalent.

Example

GET with headers → SQL Oracle UTL_HTTP

curl command
curl 'https://api.example.com/v1/users?page=2' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN'
SQL Oracle UTL_HTTP
-- The database user needs a network ACL for the host (DBMS_NETWORK_ACL_ADMIN.append_host_ace),
-- and HTTPS needs an Oracle wallet with the server's CA certificate.
SET SERVEROUTPUT ON

DECLARE
  req  UTL_HTTP.req;
  resp UTL_HTTP.resp;
  buf  VARCHAR2(32767);
BEGIN
  -- UTL_HTTP.set_wallet('file:/path/to/wallet', NULL);
  req := UTL_HTTP.begin_request('https://api.example.com/v1/users?page=2', 'GET', 'HTTP/1.1');
  UTL_HTTP.set_follow_redirect(req, 0);
  UTL_HTTP.set_header(req, 'Accept', 'application/json');
  UTL_HTTP.set_header(req, 'Authorization', 'Bearer YOUR_TOKEN');
  resp := UTL_HTTP.get_response(req);
  DBMS_OUTPUT.put_line(resp.status_code);
  BEGIN
    LOOP
      UTL_HTTP.read_text(resp, buf, 32767);
      DBMS_OUTPUT.put_line(buf);
    END LOOP;
  EXCEPTION
    WHEN UTL_HTTP.end_of_body THEN
      UTL_HTTP.end_response(resp);
  END;
END;
/

Common use cases

  • Calling APIs from PL/SQL packages and jobs
  • Sending notifications from database triggers

Converting curl to SQL Oracle UTL_HTTP

UTL_HTTP is Oracle's built-in PL/SQL package for HTTP. The code opens the request with begin_request, sets headers, writes the body, then reads the response in a loop until end_of_body.

The converter reads the curl command the way curl does — the method (-X), headers (-H), request bodies (-d, --data-raw, --json, -F), query strings, basic auth (-u) and cookies — and writes the equivalent Oracle UTL_HTTP code. Options that have no Oracle UTL_HTTP equivalent are listed under the editors rather than silently dropped.

Other libraries for SQL, each with its own page: PostgreSQL http, SQL Server.

Limitations

  • The body is a VARCHAR2 (up to 32,767 bytes); larger bodies need a CLOB written in chunks.
  • File uploads (curl -F) aren't supported.
  • The code is a starting point: add timeouts, retries and error handling for production use.
  • Secrets in the curl command are copied into the code — move them to environment variables before committing.

Frequently asked questions

Why do I get ORA-24247: network access denied by ACL?

The database user isn't allowed to connect to the host. A DBA grants it with the append_host_ace procedure of DBMS_NETWORK_ACL_ADMIN.

Why does HTTPS fail with ORA-29024?

UTL_HTTP can't verify the certificate: add the server's CA certificate to an Oracle wallet and call UTL_HTTP.set_wallet before the request.

Is there a simpler option?

On Oracle APEX, make_rest_request in the APEX_WEB_SERVICE package wraps UTL_HTTP and returns the body as a CLOB.

Is my curl command sent to a server?

No. The conversion runs entirely in your browser, so tokens and passwords in the command never leave your device. Still, replace real secrets before sharing the generated code.