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

RE: FW: http_url_post_raw



Hi Scott,
 Thanks for your help. Finally its working. Actually there is no bug in API , its just part of leveftover code which I copied from one of the archived searches I did on your forum.

Vikas Mishra
vikasm@xxxxxxxxxx
IT Applications
SCJ Insurance Services


-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Scott Klement
Sent: Wednesday, November 12, 2008 4:58 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: FW: http_url_post_raw


Hello Vikas,

So you're pasting the following into the URL/Location box on your 
browser?  If so, that's a GET request, not a POST request!!  A browser 
will only do a POST request if you do <form method="post"> in an HTML 
document, or if you use JavaScript to tell it to use POST.

If you specify everything on a normal URL, it's a GET Request.

>    https://www.myvirtualmerchant.com/VirtualMerchant/processxml.do?xml
>    data=<txn><ssl_merchant_ID>XXXXXX</ssl_merchant_ID><ssl_user_id>YYYYYY
>    </ssl_user_id><ssl_pin>ZZZZZZ</ssl_pin><ssl_transaction_type>ccsale</s
>    sl_transaction_type><ssl_card_number>5421213556478745</ssl_card_number
>    >%20%20%20<ssl_exp_date>0212</ssl_exp_date><ssl_amount>42.3</ssl_amoun
>    t><ssl_salestax>0.00</ssl_salestax><ssl_cvv2cvc2_indicator>1</ssl_cvv2
>    cvc2_indicator><ssl_cvv2cvc2>212</ssl_cvv2cvc2><ssl_customer_code>8745
>    </ssl_customer_code><ssl_first_name>John</ssl_first_name><ssl_last_nam
>    e>Muir</ssl_last_name><ssl_avs_address>1254%20Las%20Positas%20Dr</ssl_
>    avs_address><ssl_address2></ssl_address2><ssl_city>concord</ssl_city><
>    ssl_state>CA</ssl_state><ssl_avs_zip>94521</ssl_avs_zip><ssl_test_mode
>    >true</ssl_test_mode><policynumber>5039740</policynumber></txn>


I've also noticed that any place you have spaces (blanks) in the above 
URL, they have already been replaced by %20.  However, in the HTTPAPI 
version, you have not done that.

>      xmldata=
>    'xmldata=<txn><ssl_merchant_ID>XXXXXX</ssl_merchant_ID><ssl_user_id'+
>     '>YYYYYYY</ssl_user_id><ssl_pin>ZZZZZZ</ssl_pin><ssl_transaction_t'+
>     'ype>ccsale</ssl_transaction_type><ssl_card_number>542121355647874'+
>     '5</ssl_card_number><ssl_exp_date>0212</ssl_exp_date>'+
>     '<ssl_amount>42.3</ssl_amount><ssl_salestax>0.00</ssl_salestax><ss'+
>     'l_cvv2cvc2_indicator>1</ssl_cvv2cvc2_indicator><ssl_cvv2cvc2>212<'+
>     '/ssl_cvv2cvc2><ssl_customer_code>8745</ssl_customer_code><ssl_fir'+
>     'st_name>John</ssl_first_name><ssl_last_name>Muir</ssl_last_name><'+
>     'ssl_avs_address>1254 Las Positas '+
>     'Dr</ssl_avs_address><ssl_address2></ssl_address2><ssl_city>concor'+
>     'd</ssl_city><ssl_state>CA</ssl_state><ssl_avs_zip>94521</ssl_avs_'+
>     'zip></txn>' ;

Notice the blanks in "1254 Las Positas".  These are %20 in your browser 
example.

You'll notice the error message says "Invalid Request Format".  That 
could certainly be because it's expecting a GET request instead of a 
POST request.  Or, it could be that a POST request is not supposed to be 
URL encoded (Which you've sort of done... but not quite.)

My suggestion is that you change your code to look like this (this is 
off the top of my head, and untested)

      D enc             s                   like(HTTP_URL_ENCODER)
      D URL             s          32767a   varying
       /free
             .
             .. code that sets "xmldata" goes here..
             .
             enc = http_url_encoder_new();
             http_url_encoder_addvar( enc
                                    : 'xmldata'
                                    : %addr(xmldata)
                                    : %len(%trimr(xmldata)) );

             URL = 'https://www.myvirtualmerchant.com'
                 + '/VirtualMerchant/processxml.do?'
                 + http_url_encoder_getstr(enc);

             rc = http_url_get_raw( URL: 1: %paddr(Incoming));
             http_url_encoder_free(enc);

             if rc <> 1;
                // .... etc ....
             endif;

The http_url_encoder_xxx stuff is used to encode the string so that it's 
a valid part of a URL.  i.e., it'll fix the spaces!  It'll encode things 
the way a browser would...

The call to http_url_encoder_getstr() retrieves the encoded output.  I 
included it in an expression that builds the URL for the site so that 
everything is part of the URL, just as it is in your copy/paste to the 
browser.

The call to http_url_get_raw() is very similar to http_url_post_raw(), 
except that (of course!) it performs a GET request rather than a POST 
request.  Which is what the browser was doing in your example.

Like http_url_post_Raw, the http_url_get_raw routine returns 1 if it was 
successful.

I was surprised to see the following in your RPG code:

      *
      ***  bug in api    if        rc <> 1
      ***                eval      msg = http_error

Can you please explain that?  I know of no bugs in HTTPAPI that relate 
to the value of rc or http_error().  Did you find a bug, or are you just 
confused?

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