IBM Support

New HTTP functions based in QSYS2

News


Abstract

These HTTP services are used to make HTTP requests that use web services. These functions allow the
SQL programmer to use Representational State Transfer (RESTful) via SQL, including Embedded SQL. The
services provide the same capabilities as the SYSTOOLS HTTP functions without the overhead of creating
a JVM.

The services use the HTTP transport APIs that are part of the Integrated Web Services (IWS) client for ILE support.

Content

You are in: IBM i Technology Updates > Db2 for i - Technology UpdatesDb2 for i Functional Enhancements > New HTTP functions based in QSYS2

These HTTP functions exists in QSYS2 and have lower overhead than the SYSTOOLS HTTP functions.
Additional benefits of the QSYS2 HTTP functions are HTTP authentication, proxy support, configurable
redirection attempts, and configurable SSL options.


Enhanced with IBM i 7.5 SF99950 Level 5 & IBM i 7.4 SF99704 Level 26:

  • Improved HTTP header options for returning cookies

Enhanced with IBM i 7.5 SF99950 Level 4 & IBM i 7.4 SF99704 Level 25:

  • Add BLOB-based versions of QSYS2 HTTP functions

Enhanced with IBM i 7.5 SF99950 Level 3 & IBM i 7.4 SF99704 Level 23

  • HTTP options support for "headers" allows users to contain all header options within a single JSON document.

Enhanced with IBM i 7.5 SF99950 Level 1, IBM i 7.4 SF99704 Level 20, and IBM i 7.3 SF99703 Level 28:

  • Add HTTP_PATCH scalar function
  • Add HTTP_PATCH_VERBOSE table function
  • New header option, verboseResponseHeaderFormat, that specifies how the information in the RESPONSE_HTTP_HEADER column of the HTTP_xxx_VERBOSE functions is to be returned

Links to relevant documentation:

SQL programming: 

HTTP functions overview

SQL Reference

HTTP_GET and HTTP_GET_BLOB scalar function

HTTP_GET_VERBOSE and HTTP_GET_BLOB_VERBOSE table function

HTTP_POST and HTTP_POST_BLOB scalar function

HTTP_POST_VERBOSE and HTTP_POST_BLOB_VERBOSE table function

HTTP_PUT and HTTP_PUT_BLOB scalar function

HTTP_PUT_VERBOSE and HTTP_PUT_BLOB_VERBOSE table function

HTTP_DELETE and HTTP_DELETE_BLOB scalar function

HTTP_DELETE_VERBOSE and HTTP_DELETE_BLOB_VERBOSE table function

HTTP_PATCH and HTTP_PATCH_BLOB scalar function

HTTP_PATCH_VERBOSE and HTTP_PATCH_BLOB_VERBOSE table function

URL_ENCODE scalar function

URL_DECODE scalar function

BASE64_ENCODE scalar function

BASE64_DECODE scalar function

Configure TLS/HTTPS secure communications link:

SSL Considerations for QSYS2 HTTP Functions



Simple examples:

--
-- Confirm that a basic Rest call is successful
--

VALUES QSYS2.HTTP_GET(
  URL     => 'https://www.ibm.com/support/pages/sites/default/files/inline-files/xmldoc.xml',       
  /* CLOB(1 MB)  No default       */
  OPTIONS => DEFAULT  
  /* CLOB(1 MB)  Default: Null    */
);
--
-- Example of HTTP_GET_VERBOSE returning failure detail
--

select *
  from table (
      QSYS2.HTTP_GET_VERBOSE('http://www.w3.org/notfound.html', '')
    );
--
-- BASE64 Encode example
--

VALUES QSYS2.BASE64_ENCODE('myuser:mypassword');
-- lKikooWZepSol4GioqaWmYQ=
--
-- BASE64 Decode example
--

VALUES varchar(QSYS2.BASE64_DECODE('lKikooWZepSol4GioqaWmYQ='), 80));
-- myuser:mypassword
--
-- URL Encode example
--

VALUES 'https://www.example.com/search?q=' CONCAT URL_ENCODE('IBM i Q&A');
--
-- URL Decode example
--

VALUES URL_DECODE('https://www.example.com/search?q=IBM+i+Q%26A');

json headers

image-20230407123235-1

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"ARM Category":[{"code":"a8m0z0000000CHeAAM","label":"IBM i Db2"}],"ARM Case Number":"","Platform":[{"code":"PF012","label":"IBM i"}],"Version":"7.3.0;and future releases"}]

Document Information

Modified date:
18 February 2024

UID

ibm16486889