hi Mike,

On 6/15/2011 3:26 PM, Smith, Mike wrote:
I have a project where I need to call a url(that accesses our document
management system) from within an RPG program.


I did some searching, but couldn't find any docs for the "api-create" tool at tinyurl... I found lots of 3rd party tips referencing it, but nothing official from TinyURL. But, from experimenting, it seems to be using the GET method, not POST.

Here's an example of how I would code that (but I'm not familiar with all of your requirements, so I may be doing something wrong.. hopefully you can adapt it):

H DFTACTGRP(*NO) BNDDIR('HTTPAPI')

/define WEBFORMS
/copy httpapi_h

D raw_receiver PR 10i 0
D fd 10i 0 value
D data 65535a options(*varsize)
D len 10i 0 value

D rc s 10i 0
D form s like(WEBFORM)
D Url s 500a varying
D LongVersion s 256a
D ShortVersion s 50a varying

/free
LongVersion = 'http://rgc-filenexus/FileNexus/+
BrowserClient/directlink.aspx?+
fid=58&cid=32&iid=23&iv=100377101';

// encode the data the way a browser would
// if entered into an HTML form:

form = WEBFORM_open();
WEBFORM_setVar( form: 'url': %trimr(LongVersion) );
url = 'http://tinyurl.com/api-create.php?'
+ WEBFORM_getData(form);
WEBFORM_close(form);


// Send with GET method:
// (note: I'm using get_raw so I don't have to
// save to/from disk)

ShortVersion = '';

rc = http_url_get_raw( url
: -1
: %paddr(raw_receiver) );

if (rc <> 1);
http_crash();
endif;

// This is just for demo purposes.
dsply ShortVersion;

*inlr = *on;
/end-free


*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* raw_receiver: This receives raw HTTP data as it arrives
* from the network.
*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
P raw_receiver B
D PI 10i 0
D fd 10i 0 value
D data 65535a options(*varsize)
D len 10i 0 value
/free
if (len > 0);
HTTP_xlate( len: data: TO_EBCDIC );
ShortVersion += %subst(data:1:len);
endif;
return len;
/end-free
P E


This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].