[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: http_persist_req( 'GET') method
[cid:image001.gif@01D164AA.50AAE510]
Thank Scott for quick response. It was the conversion to EBCDIC that gave me
an issue. It now works. So you have saved yet another keyboard! The only
reason I was trying this with http_persist_req(`get') was that I need to try
to find answer to a PATCH method. My current process does use
http_url_post_stmf. I do a delete first so it will add the new records
(which may be just and update but can't find anything on a PATCH method. If
you can direct me to something that how to do a PATCH method then all will be
good in the world.
I will try the http_get..
Thanks again for quick response.
Re: http_persist_req( 'GET') method
_______________________________________________________________________
* From: Scott Klement <[1]sk@xxxxxxxxxxxxxxxx>
* To: HTTPAPI and FTPAPI Projects <[2]ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
* Subject: Re: http_persist_req( 'GET') method
* Date: Thu, 11 Feb 2016 00:19:21 -0600
_______________________________________________________________________
Hi Drew,
In my opinion, you are doing this the "hard way" by
using http_persist_req(). What is your reason for using that instead
of http_get() or http_url_get_raw()?
But, no matter -- if you prefer to use http_persist_req(), it'll
work. The data is being passed back to your program via the
'mysaveproc' that you've coded. Each time some data arrives over the
network, that procedure is called with the data. so it can be called
many times, each time feeding whatever data has just arrived.
If your goal is to put that data into a string variable, then just
code that in your procedure. For example:
ResultString = ''; // this is a "VARYING" string.
... call http_persist_xxx routines here....
p mysaveproc b
d pi 10i
d fd 10i 0 value
d data 65535a options(*varsize)
d length 10i 0 value
/free
if length > 0;
resultString = resultString + %subst(data:1:length);
endif;
return length;
p mysaveproc e
when http_persist_req() returns control back to it's
caller, "resultString" will be filled in with all of the data that
arrived over the network. It will be in the same character encoding
that was sent from the server (probably UTF-8) but you can call one of
the http_xlate() routines to convert it to EBCDIC if you desire. Or, if
on V7R2, you could use RPG's built-in UTF-8 support for that stuff
by adding the appropriate CCSID keywords, etc.
Hope that helps.
On 2/10/2016 10:34 PM, Drew White wrote:
[cid:image001.gif@01D16452.87082990]
All,
Can someone provide a working example (rpg) that show how to retrieve
data returned by using the http_persist_req( 'GET') method? I have
code that works but now sure how to parse the json it returns. I can
tell by the logs that it works. I just can't determine how to get the
json data returned back into a variable so I can evaluate it.
Any help appreciated.
Example of call:
Pointer = http_persist_open( URL );
if (pointer = *null);
RETURN;
endif;
monitor;
http_persist_req( 'GET'
: pointer
: url
: 0
: *null
: *null
: 0
: peFD
: %paddr(mysaveproc));
on-error;
rc=rc;
endmon;
http_persist_close( Pointer );
p mysaveproc b
d pi 10i
d fd 10i 0 value
d data * value
d length 10i 0 value
return length;
p mysaveproc e
Log
SetError() #0:
[
{
"id": "5397a88f-5071-45c4-80cb-a5a7018155e7",
"keyColumn": "0000041",
"value":
"\"[\\\"41\\\",\\\"0\\\",\\\"0\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"0\\\"
,\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"\\\",\\\"TARRANTDREW\\\"]\"",
"url": null
}
]
http_close(): entered
HTTPAPI Ver 1.29 released 2015-02-23
NTLM Ver 1.4.0 released 2014-12-22
OS/400 Ver V7R1M0
http_setauth(): entered
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
[3]http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------
_______________________________________________________________________
* References:
+ [4]http_persist_req( 'GET') method
o From: Drew White
* Prev by Date: [5]http_persist_req( 'GET') method
* Previous by thread: [6]http_persist_req( 'GET') method
* Index(es):
+ [7]Date
+ [8]Thread
Drew White
Programmer Analyst
903-885-1283 x4207
800-621-8030 x4207
dwhite@xxxxxxxxxxxxxxxxxxx
Email FE logo2
Confidentiality Statement: This electronic mail transmission is
confidential, may be privileged and should be read or retained only by
the intended recipient. If you have received this transmission in
error, please notify the sender immediately and delete it from your
system.
References
1. mailto:sk@DOMAIN.HIDDEN
2. mailto:ftpapi@DOMAIN.HIDDEN
3. http://www.scottklement.com/mailman/listinfo/ftpapi
4. http://scottklement.com/archives/ftpapi/201602/msg00028.html
5. http://scottklement.com/archives/ftpapi/201602/msg00028.html
6. http://scottklement.com/archives/ftpapi/201602/msg00028.html
7. http://scottklement.com/archives/ftpapi/201602/maillist.html#00029
8. http://scottklement.com/archives/ftpapi/201602/threads.html#00029


-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------