We help IT Professionals succeed at work.

LIBHTTP Post result

Medium Priority
78 Views
Last Modified: 2019-03-09
Hi experts,

I use LIBHTTP to call a restservice (POST)
On this moment I use :
http_post(URL                         
         : %addr(myJSON:*data )       
         : %len(%trim(myJSON))        
         : '/home/user/result.dta' 
         : HTTP_TIMEOUT               
         : HTTP_USERAGENT             
         : 'application/json' );  

Open in new window

The result is written to a resultfile, I prefer to get the result in a variable in the program,
what do I have to change to accomplish that?
Comment
Watch Question

David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
I tried reading through the http_post IBM docs.

As usual, IBM docs seem to leave out 99% of what's required to get their code to work.

Looks like you must register a function as a callback to use data, rather than output to a file.

Seems like a massive amount of overkill. You may be better off just making a callout to a command line tool, like curl, so your POST processing is synchronous/inlined rather than callback based.

Or you can always attempt to understand IBM's docs about how to build your callback to do asynchronous processing of your data.

Tip: Because IBM docs are so... barely understandable... Best you actually post a link to docs for http_post() you're using, as it's unclear I was even reading the correct docs.
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Author

Commented:
Hi David,

Oke that is what I fond until now, I hoped there were some features I didn't discover.

Curl on iSeries?
is that a Qshell program?
standard or do I have to install that?
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
You may have to build curl for your machine or find a per-built version.

Unsure about qsh (Qshell). IBM docs suggest this may already be installed on your machine.
Theo KouwenhovenApplication Consultant
CERTIFIED EXPERT

Author

Commented:
CURL seems to be a nice option, but not flexible enough.
I need the possibility  to send a (large) IFS file and not in a 72K commandline.