[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: HTTPAPI http_url_get



Hi,

That's interesting, I'm running at 7.1

John

-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Rainer Ross
Sent: 28 October 2016 09:51
To: HTTPAPI and FTPAPI Projects <ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
Subject: Re: HTTPAPI http_url_get


Hi John,

when you are on V7.1 or higher you can load the result of the GET request with SQL into a variable

         ctl-opt main(main) dftactgrp(*no) option(*nounref); //------------------------------------------------------------------//
// //
       // GETHTTPCLOB from Google Maps
API                                 //
// //
//----------------- //
       // R.Ross 10.2016
*                                                 //
//------------------------------------------------------------------//
       // Variables //
//------------------------------------------------------------------//

          dcl-s   myclob      SQLType(CLOB:1000000) inz; // CLOB
          dcl-s   myurl       varchar(256);              // URL
          dcl-s   query       varchar(256);              // QueryString
          dcl-s   mydata      varchar(30000);            // Data

//------------------------------------------------------------------//
       // Procedure -
Main                                                 //
//------------------------------------------------------------------//
          dcl-proc main;

            exec sql set option datfmt=*iso, timfmt=*iso, commit=*none,
                                closqlcsr=*endactgrp;

            myurl = 'https://maps.googleapis.com/maps/api/geocode/xml?' +
                    'address=';
            query = '3605 US-52, Rochester, MN';

            exec sql set :query = systools.urlencode(:query,'UTF-8');
            myurl += query;                            // URL + QueryString

            exec sql
             SELECT SYSTOOLS.HTTPGETCLOB (:myurl,'')
               into :myclob
               From SYSIBM.SYSDUMMY1;

             if sqlcode >= *zero;
                mydata = %subst(myclob_data:1:myclob_len); // CLOB -> Data
             endif;

          end-proc;
//------------------------------------------------------------------//

regards

Rainer

--
Rainer Ross
IT-Consulting
www.myhofi.com - a smarter way to book hotels - powered by IBM i
86916 Kaufering, Germany



Am 27.10.2016 um 16:13 schrieb John Long:
>     Hi All,
>
>
>     I need to receive a CSV file that is generated when I issue  a HTTP
>     GET,  I know I can use http_url_get specifying the URL and file name in
>     the IFS,
>
>
>     Is there a way that I can get the file straight into memory and
>     manipulate it there rather than having it automatically stored in the
>     IFS and then accessing from there?
>
>
>     Thanks in advance
>
>
>     John
>
>
>
>
>     _____________________________________________________________ T.J.
>     MORRIS LTD-CONFIDENTIALITY NOTICE This e-mail and its contents,
>     together with any attachments, are confidential to the sender and the
>     intended recipient(s). If you are not the intended recipient or agent
>     responsible for delivery to the intended recipient any unauthorised
>     storage, use, disclosure, copying, distribution or dissemination of
>     this e-mail or any part thereof is strictly prohibited and may be
>     illegal. If you receive this e-mail in error please advise us by
>     telephone on +44(0)151 530 2920 and delete and destroy this e-mail and
>     any attachments and any copies thereof from your system immediately.
>     Any views or opinions expressed in this e-mail are solely those of the
>     sender and do not necessarily represent those of T J Morris Ltd.
>     Although any attachments to this e-mail have been checked for viruses
>     we make no representation and give no warranty as to the absence of
>     viruses and you should scan this e-mail and attachments for viruses.
>     ___________________________________________________________
>
>
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list.  To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------


_____________________________________________________________ T.J. MORRIS LTD-CONFIDENTIALITY NOTICE This e-mail and its contents, together with any attachments, are confidential to the sender and the intended recipient(s). If you are not the intended recipient or agent responsible for delivery to the intended recipient any unauthorised storage, use, disclosure, copying, distribution or dissemination of this e-mail or any part thereof is strictly prohibited and may be illegal. If you receive this e-mail in error please advise us by telephone on +44(0)151 530 2920 and delete and destroy this e-mail and any attachments and any copies thereof from your system immediately. Any views or opinions expressed in this e-mail are solely those of the sender and do not necessarily represent those of T J Morris Ltd. Although any attachments to this e-mail have been checked for viruses we make no representation and give no warranty as to the absence of viruses and you should scan this e-mail and attachments for viruses. ___________________________________________________________
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------