Subscription Key in Header
Posted: Tue Oct 15, 2024 10:19 am
We are trying to pass a json data to an APIM server using HTTPAPI in RPGLE. We tried to provide the subscription key using http_setAuth method but they are asking to send this in header. How to define the subscription key in Header to connect an APIM server using RPGLE? Following is our program.
* =================================================================
* Program Id : WT1
* File Desc : Test AS400/web service for Pick Pack shiphip
* Author : Thisaru Dheerarathna
* Date : 25/09/2024
* =================================================================
/if defined(*CRTBNDRPG)
H DFTACTGRP(*NO)
/endif
H BNDDIR('HTTPAPI')
/copy httpapi_h
/copy ifsio_h
D QCMDEXC pr extpgm('QCMDEXC')
D command 200A const
D length 15P 5 const
D msg s 52A
H BNDDIR('HTTPAPI')
/copy httpapi_h
/copy ifsio_h
D QCMDEXC pr extpgm('QCMDEXC')
D command 200A const
D length 15P 5 const
D msg s 52A
D rc s 10I 0
D url S 256A
D jsonFilePath S 256A
D ContentType s 256A
**FREE
http_debug(*on:'/tmp/baba-diagnostic-log.txt');
jsonFilePath =
'/NPS/PMMK/PMMK321_20241006_230519_20241006230519114.JSON';
http_setOption('content-type': 'application/json');
rc = http_req( 'POST'
:'https://endpoint URL'
: '/tmp/testpost.html' // File to receive
: *omit // String to receiv
: jsonFilePath // File to send
: *omit); // String to send
Any guidance will be helpful. If you need any further information, feel free to contact me.
* =================================================================
* Program Id : WT1
* File Desc : Test AS400/web service for Pick Pack shiphip
* Author : Thisaru Dheerarathna
* Date : 25/09/2024
* =================================================================
/if defined(*CRTBNDRPG)
H DFTACTGRP(*NO)
/endif
H BNDDIR('HTTPAPI')
/copy httpapi_h
/copy ifsio_h
D QCMDEXC pr extpgm('QCMDEXC')
D command 200A const
D length 15P 5 const
D msg s 52A
H BNDDIR('HTTPAPI')
/copy httpapi_h
/copy ifsio_h
D QCMDEXC pr extpgm('QCMDEXC')
D command 200A const
D length 15P 5 const
D msg s 52A
D rc s 10I 0
D url S 256A
D jsonFilePath S 256A
D ContentType s 256A
**FREE
http_debug(*on:'/tmp/baba-diagnostic-log.txt');
jsonFilePath =
'/NPS/PMMK/PMMK321_20241006_230519_20241006230519114.JSON';
http_setOption('content-type': 'application/json');
rc = http_req( 'POST'
:'https://endpoint URL'
: '/tmp/testpost.html' // File to receive
: *omit // String to receiv
: jsonFilePath // File to send
: *omit); // String to send
Any guidance will be helpful. If you need any further information, feel free to contact me.