Subscription Key in Header

Discussions related to HTTPAPI (An HTTP Client Package for RPG programming.) http://www.scottklement.com/httpapi/
Post Reply
balinabk
Posts: 3
Joined: Tue Oct 15, 2024 10:15 am

Subscription Key in Header

Post 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.
Last edited by balinabk on Wed Oct 16, 2024 1:45 am, edited 1 time in total.
Scott Klement
Site Admin
Posts: 872
Joined: Sun Jul 04, 2021 5:12 am

Re: Subscription Key in Header

Post by Scott Klement »

What is the header you need to pass it in? Do you have an example of what it looks like?
balinabk
Posts: 3
Joined: Tue Oct 15, 2024 10:15 am

Re: Subscription Key in Header

Post 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.
balinabk
Posts: 3
Joined: Tue Oct 15, 2024 10:15 am

Re: Subscription Key in Header

Post by balinabk »

Thanks for the information Scott. We managed to resolve the issue by using additional headers exit point process in HTTPAPI.
Post Reply