IBM i Global

 View Only
Expand all | Collapse all

IWS - SQL as a Web service - calling a SQL procedure and returning a result set

  • 1.  IWS - SQL as a Web service - calling a SQL procedure and returning a result set

    Posted Mon July 25, 2022 08:48 AM

    We are currently converting our SQL stored procedures to a REST web service "call" via IWS and SQL.

    The stored procedure accepts 3 parameters, calls an RPG program that will insert records into a table and then the stored procedure returns a result set.

    When I "hard code" the call in the SQL REST service, I get the result set returned.

    BUT, when I parameterize the SQL REST service call, I get a 415 "Unsupported Media Type" message (testing via Postman).

    What should I change on the SQL REST service configuration (if any) to get the "parameterized" call to return the result set?

    Thanks for your assistance

    Here is the code for the SQL stored procedure

    IWS configuration for the "hard-coded" SQL call and the result set returned.

    And the IWS configuration for the "parameterized" SQL call.



    ------------------------------
    Dennis Nel
    ------------------------------



  • 2.  RE: IWS - SQL as a Web service - calling a SQL procedure and returning a result set

    Posted Tue July 26, 2022 03:33 AM

    I have managed to solve the issue.

    You need to specify the Allowed input media type when configuring the HTTP request method

    In this case I was specifying the input parameters in the body as JSON and specified the input media type as such



    ------------------------------
    Dennis Nel
    ------------------------------



  • 3.  RE: IWS - SQL as a Web service - calling a SQL procedure and returning a result set

    Posted Wed July 27, 2022 10:34 AM
    Glad you were able to figure it out. 

    If your SQL Stored Procedure is called repeatedly within the job, you should add the PROGRAM TYPE SUB option to your definition to improve performance.
    If you have questions on this SQL syntax, you can post in the SQL group

    ------------------------------
    Kent Milligan
    ------------------------------