Page 1 of 1

Subscription Key in Header

Posted: Tue Oct 15, 2024 10:19 am
by balinabk
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.

Re: Subscription Key in Header

Posted: Tue Oct 15, 2024 1:17 pm
by Scott Klement
What is the header you need to pass it in? Do you have an example of what it looks like?

Re: Subscription Key in Header

Posted: Wed Oct 16, 2024 1:38 am
by balinabk
Hi Scott,

We need to pass the following values for authorization.

Key name and key value lime api-key: "key value".

If you need any further information, feel free to contact me.

Re: Subscription Key in Header

Posted: Wed Oct 16, 2024 8:25 pm
by Scott Klement

Re: Subscription Key in Header

Posted: Mon Oct 21, 2024 9:40 am
by balinabk
Thanks for the information Scott. We managed to resolve the issue by using additional headers exit point process in HTTPAPI.