You can also use http_req(). It allows you to specify the type of request (i.e. POST) and independently select whether your payload and response is a variable or streamfile.
rc = http_req('POST'
: URL
: '/myifsFile'
: *omit
: *omit
: jsonBodyRPGvariable
: 'application/json');
Here is the prototype descriptions from RDI:
http_req( Type VARCHAR(10: 2) CONST:
URL VARCHAR(32767: 2) CONST:
ResultStmf VARCHAR(5000: 2) CONST OPTIONS(*OMIT: *VARSIZE):
ResultStr VARCHAR(16000000: 4) OPTIONS(*NOPASS: *OMIT: *VARSIZE):
SendStmf VARCHAR(5000: 2) CONST OPTIONS(*NOPASS: *OMIT: *VARSIZE):
SendStr VARCHAR(16000000: 4) CONST OPTIONS(*NOPASS: *OMIT: *VARSIZE):
ContentType VARCHAR(16384: 2) CONST OPTIONS(*NOPASS: *OMIT: *VARSIZE)
) http_req : INT(10) EXTPROC ( 'HTTP_REQ' )
-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxxxxxxxx] On Behalf Of (WalzCraft) Jerry Forss
Sent: Tuesday, September 01, 2020 4:24 PM
To: 'RPG programming on IBM i' <rpg400-l@xxxxxxxxxxxxxxxxxx>
Subject: http_post
I have a json doc (jsonRequest) on the ifs but am having trouble sending it with the http_post.
I am unsure what to put into parameters 2 and 3.
The examples I am finding online use a variable from the pgm.
rc = http_post( URL
: %addr( WhatdDoIPutHere : *data )
: %len( WhatdDoIPutHere )
: 'IFS/jsonRequest.json'
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'application/json' );
Subject to Change Notice:
WalzCraft reserves the right to improve designs, and to change specifications without notice.
Confidentiality Notice:
This message and any attachments may contain confidential and privileged information that is protected by law. The information contained herein is transmitted for the sole use of the intended recipient(s) and should "only" pertain to "WalzCraft" company matters. If you are not the intended recipient or designated agent of the recipient of such information, you are hereby notified that any use, dissemination, copying or retention of this email or the information contained herein is strictly prohibited and may subject you to penalties under federal and/or state law. If you received this email in error, please notify the sender immediately and permanently delete this email. Thank You
WalzCraft PO Box 1748 La Crosse, WI, 54602-1748
www.walzcraft.com<
http://www.walzcraft.com> Phone: 1-800-237-1326
As an Amazon Associate we earn from qualifying purchases.