IBM i Global

 View Only

 HTTP_POST - issue passing bearer token

Arthur Whitehouse's profile image
Arthur Whitehouse posted Wed January 28, 2026 09:06 AM

Hi I'm using HTTP_POST and need to pass a bearer token that I'm retrieving in a previous step.

I've been trying many variations syntax wise that I've found through searches but so far I haven't been able to get it to work.

Any help would be greatly appreciated, I'm tearing my hair out at this point trying to figure it out.

BTW our iseries is at V7R3M0.

This is the latest version I've tried.

  values QSYS2.HTTP_POST(

           'http://10.2.2.9:9081/apex/n4restapiservice/holtUnitDM/v1/',

           '{"equipmentId":"CAXU5289230","category":"IMPORT","freightKind":"FULL"}',

           '{"headers": {"header": ["Content-Type,application/json","Authorization,Bearer2f2da8ea-8266-408b-bbf9-9024d96c0634"]}}'

         )

the error I received is below.

Vendor Code: -443
Message: [SQL0443] ERROR  : INVALID HEADERS JSON OPTION AT OFFSET 1 reason:-3 Cause . . . . . :   Either a trigger program, external procedure, or external function detected and returned an error to SQL. If the error occurred in a trigger program, the trigger was on table QSQAXISC in schema QSYS. If the error occurred in an external procedure or function, the external name is QSQAXISC in schema QSYS.  The associated text is ERROR  : INVALID HEADERS JSON OPTION AT OFFSET 1 reason:-3.  If the error occurred in a trigger program, the associated text is the type of trigger program.  If the error occurred in an external function, the associated text is the text of the error message returned from the external function.

Here's another variation I've tried and the error I'm receiving.

 values QSYS2.HTTP_POST(

           'http://10.2.2.9:9081/apex/n4restapiservice/holtUnitDM/v1/',

           '{"equipmentId":"CAXU5289230","category":"IMPORT","freightKind":"FULL"}',

                       '{"header":"Content-Type,application/json","Authorization":"Bearer e52ebb5c-c285-41c9-9877-2b1f189ddaab"}'

                       );

Message: [SQL0443] ERROR  : INVALID PROPERTY : Authorization Cause . . . . . :   Either a trigger program, external procedure, or external function detected and returned an error to SQL. If the error occurred in a trigger program, the trigger was on table QSQAXISC in schema QSYS. If the error occurred in an external procedure or function, the external name is QSQAXISC in schema QSYS.  The associated text is ERROR  : INVALID PROPERTY : Authorization.  If the error occurred in a trigger program, the associated text is the type of trigger program.  If the error occurred in an external function, the associated text is the text of the error message returned from the external function. Recovery  . . . :   Refer to the joblog for more information regarding the detected error. Correct the error and try the request again.

Paul Nicolay's profile image
Paul Nicolay

This is how I did it for the old SYSTOOLS.HTTPGETCLOB function, probably it is similar in JSON;

Headers = '<httpHeader>'                                                       
        + '  <header name="Host" value="api.businesscentral.dynamics.com" />'  
        + '  <header name="Authorization" value="Bearer your_access_token" />'     
        + '  <header name="Accept" value="application/json" />'                
        + '</httpHeader>';      

                                              

Thomas BARBEROT's profile image
Thomas BARBEROT

Can you try this:

values QSYS2.HTTP_POST('http://10.2.2.9:9081/apex/n4restapiservice/holtUnitDM/v1/',
         
            '{"equipmentId":"CAXU5289230","category":"IMPORT","freightKind":"FULL"}',
                       '{"headers":{"Content-Type":"application/json", "Authorization":"Bearer e52ebb5c-c285-41c9-9877-2b1f189ddaab"}}'

                      );

Paul Nicolay's profile image
Paul Nicolay

BTW, the JSON syntax can be found at HTTP_GET and HTTP_GET_BLOB - IBM Documentation