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

Web services



Hello Scott:

I have return back to the PayTrace Project to find out more details 

Accordingly all the data looks good except that all the portion of the
request following the "ParmList=" designation should be URL Encoded

This is what the postdata looks like in the program, of course we are doing
the testing so right now the data is hard coded.

postData =                                                       
  'https://paytrace.com/api/default.pay?'                      + 
    'parmList='                                                  + 
  'UN~demo123' + '|' + 'PSWD~demo123' + '|' + 'TERMS~Y' + '|'  + 
  'METHOD~ProcessTranx' + '|' + 'TRANXTYPE~Authorization' + '|'+ 
  'CC~4012881888818888' + '|' + 'EXPMNTH~12' + '|' + 'EXPYR~12'+ 
  '|' + 'AMOUNT~1.00' + '|' + 'CSC~999' + '|' + 'BADDRESS~1234'+ 
   '|' + 'BZIP~83852' + '|' + 'INVOICE~8888' + '|'             ; 
                                                                 
rc = http_url_post('https://paytrace.com/api/default.pay?'       
                      : %addr(postData:*DATA)                    
                      : %len(%trimr(postData))                   
                      : '/tmp/httptest.html');                   

Does HTTPAPI have a tool to do the parmList in URL Encoded format?

Please advise

Thank you


Regards,

Carlos Lugo


-----Original Message-----
From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
[mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
Sent: Thursday, October 18, 2012 10:56 PM
To: HTTPAPI and FTPAPI Projects
Subject: Re: FW: Web services

Hi Carlos,

Please understand that HTTPAPI is a file transfer program.  It's job is to
send either a string containing data, or a file containing data from your
computer to another computer.  According to your logs, it's doing that,
successfully.

Your question is about what to put in the string that's sent to someone 
else's web service.  (Someone called "Paytrace", I gather.)   If this 
was a web service that I was familiar with, I'd be more than happy to share
my knowledge.  But, unfortunately, I'm not familiar with Paytrace.

Normally, a web service will provide documentation on how to use it.  
This might be in the form of a WSDL document (which is the norm with SOAP
web services) or it might be in the form of a human-readable documentation,
such as HTML, PDF or Word format.  Did they give you anything like this?
Because this is where you should start -- learn how to call the service.

Once you know what the service is expecting, and your question is how to
accomplish that with HTTPAPI, let me know, and I'll be glad to help.

You mention URL encoding -- and I don't exactly know how you want URL
encoding to come into play here?  Is it that you have the equivalent of an
HTML form, and it has one variable named 'parmlist', and in that 
variable you wish to put all of the pipe-delimited data you posted?    
If that's the case (and I don't know how I could know that, again, remember,
I'm not familiar with Paytrace) you would do it like this:

  /define WEBFORMS
  /copy httpapi_h

D form            s like(WEBFORM)
D postData        s *
D postDataLen     s             10i 0

D parmlist        s          40000A varying

  /free

    form = WEBFORM_open();

    parmlist = 'UN~demo123|PSWD~demo123|TERMS~Y|METHOD~ProcessTranx|'
             + 'TRANXTYPE~Authorization|CC~4012881888818888|EXPMNTH~12|'
             + 'EXPYR~12|AMOUNT~1.00|CSC~999|BADDRESS~1234|BZIP~83852|'
             +  'INVOICE~8888|';

    WEBFORM_setPtr( form
                  : 'parmlist'
                  : %addr(parmlist : *data)
                  : %len(parmlist) );

    WEBFORM_postData( form
                    : postData
                    : postDataLen );

    rc = http_url_post( 'https://paytrace.com/api/default.asp'
                      : postData
                      : postDataLen
                      : '/tmp/httptest.html' );

    WEBFORM_close(form);


I have no clue whether this is correct or not -- it's purely a guess, and
it's based ENTIRELY on the example you posted, so if your code is wrong,
then mine certainly will be, too.

I'm a little confused by the way you're calling http_url_post() as well.
You've added a ? to the URL, which typically denotes a query string -- but
you didn't provide any query strings.  Did you intend for 
this data to be passed as a query string rather than as post data?   
That, again, is one of those details that should be documented by the WS
provider, and is something I wouldn't know. You need to read their docs to
find out.

Also, if it is meant to be a query string, are you certain that you wanted
to do a POST request?  a query string is typically used with a GET request.
Again.. to know, you need to read their docs.
If you _are_ sending this as a post request, what Content-Type is desired?
You are specifying HTTPAPI's default value of text/xml -- and 
your data is clearly NOT xml.   Maybe it should be set to 
application/x-www-form-urlencoded?  Again, to know, you need to read their
docs.

-SK


On 10/18/2012 6:29 PM, J. Carlos Lugo wrote:
> Hello Scott:
>
> I have remove now the doble "||" character from the program, but still I
get
> the same error
> ERROR~990. Please provide a properly formatted parameter string.|
>
> Pay trace is expecting the entire POSTDATA as URL Encoded they are saying
> that what I am sending is not URL Encoded.
> Does HTTP API does the encode or I have to do something else or use a
> different API from your Tool
>
> Please advise
>
>
> Regards,
>
> Carlos Lugo
>
> Multitec Consultants Group Inc.
>
> ( 310-717-7327
>
> JCLUGO@xxxxxxxxx
>
>
> -----Original Message-----
> From: J. Carlos Lugo [mailto:jclugo@xxxxxxxxx]
> Sent: Monday, October 15, 2012 10:07 AM
> To: 'HTTPAPI and FTPAPI Projects'
> Subject: RE: Web services
>
> Hello Scott:
>
> Thank you for your answer, Yes the Postdata is a Varying field
> D postData        s          40000A   varying
>
> We are running V6R1 and this is how the Post data Look in the Program and
> when is doing the Post
> postData =
>    'parmlist='                                                  +
>    'UN~demo123|PSWD~demo123|TERMS~Y|METHOD~ProcessTranx|'       +
>    'TRANXTYPE~Authorization|CC~4012881888818888|EXPMNTH~12|'    +
>    'EXPYR~12|AMOUNT~1.00|CSC~999|BADDRESS~1234|BZIP~83852|'     +
>    'INVOICE~8888|'                                              ;
>                                                                     
> rc = http_url_post('https://paytrace.com/api/default.pay?'
>                        : %addr(postData:*DATA)
>                        : %len(%trimr(postData))
>                        : '/tmp/httptest.html');
>
>
> Now I do not see the Special character anymore but now Still Paytrace is
> sending me the following error below:
>
> ERROR~990. Please provide a properly formatted parameter string.|
>
>
> See the attached Text File for the Debug Log
>
> I really appreciate all your help that you provide to all of us in using
> your excellent tool for web services.
>
>
> Regards,
>
> Carlos Lugo
>
> Multitec Consultants Group Inc.
>
> ( 310-717-7327
>
> JCLUGO@xxxxxxxxx
>
> -----Original Message-----
> From: ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:ftpapi-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Scott Klement
> Sent: Friday, October 12, 2012 3:51 PM
> To: HTTPAPI and FTPAPI Projects
> Subject: Re: Web services
>
> Hi Carlos,
>
> My guess would be that postData is a VARYING field.  This is just a guess,
> because you did not include the definition of this field in your message,
> but it would explain the behavior you're seeing.
>
> VARYING fields are stored in memory as a 2 or 4 byte unsigned integer that
> keeps track of the current length of the field, followed by the actual
> characters in the field.  So if your postData variable is 65535
> long or shorter, the first two bytes in memory would be the length.
> When you pass %addr(postData) to HTTPAPI, the address you're supplying
> points to those length bytes, so HTTPAPI dutifully sends those length
bytes
> to the server.
>
> That's why in some of my examples, you'll see me do:  %addr(myVar) +
> 2.    The +2 provides an address that's two bytes higher -- i.e. it
> skips over those two length bytes.   On V6R1 and higher, IBM gave us a
> way to do that automatically with %ADDR(myVar:*DATA), which is better
> because it's more self-documenting.
>
> Anyway, try changing your code to %ADDR(postData: *DATA) or if you're
still
> on V5R4 or earlier, do %ADDR(postData)+2 and see if that solves the
problem.
>
> Good luck!
>
>
>
> On 10/12/2012 1:48 PM, J. Carlos Lugo wrote:
>>      Hello All:
>>
>>
>>      I am submitting a HTTP Post to Pay Trace web services but when pay
>>      trace received my Data String shows a weird character
>>
>>
>>      Here is the Data String submitted to Pay Trace
>>
>>      Hello, and thank you for contacting Pay Trace.
>>
>>
>>      We can see ' ¬- ' before the parmlist. Beyond that it is formatted
>>      correctly. Here is the same information without the ' ¬- ' in there
>>      which works correctly when submitted through a browser.
>>
>>
>>
> [1]https://paytrace.com/api/default.pay?parmlist=UN~demo123|PSWD~demo12
> 3|TERMS~Y|METHOD~ProcessTranx|TRANXTYPE~Authorization|CC~40128818888188
> 88|EXPMNTH~12|EXPYR~12|AMOUNT~1.00|CSC~999|BADDRESS~1234|BZIP~83852|INV
>>      OICE~8888|
>>
>>
>>
>>      HERE is your string
>>
>>
>>      [2]https://paytrace.com/api/default.pay?
>>
>>
> ¬-parmlist=UN~demo123|PSWD~demo123|TERMS~Y|METHOD~ProcessTranx|TRANXTYP
> E~Authorization|CC~4012881888818888|EXPMNTH~12|EXPYR~12|AMOUNT~1.00|CSC
>>      ~999|BADDRESS~1234|BZIP~83852|INVOICE~8888|
>>
>>
>>
>>      Here is what I have in the program to test the HTTP Post
>>
>>      postData =
>>
>>        'parmlist='                                                  +
>>
>>        'UN~demo123|PSWD~demo123|TERMS~Y|METHOD~ProcessTranx|'       +
>>
>>        'TRANXTYPE~Authorization|CC~4012881888818888|EXPMNTH~12|'    +
>>
>>        'EXPYR~12|AMOUNT~1.00|CSC~999|BADDRESS~1234|BZIP~83852|'     +
>>
>>        'INVOICE~8888|'+ CRLF                                        ;
>>
>>
>>      rc = http_url_post('https://paytrace.com/api/default.pay?'
>>
>>                            : %addr(postData)
>>
>>                            : %len(%trimr(postData))
>>
>>                            : '/tmp/httptest.html');
>>
>>
>>
>>      Any advise will be appreciate it if I am using the right
HTTP_URL_POST
>>      or should I use a Different POST Process to void the character that
>>      they Pay trace found in my data string.
>>
>>      http_url_post_raw?
>>
>>
>>
>>      Regards,
>>
>>      Carlos Lugo
>>
>>      Multitec Consultants Group Inc.
>>
>>      ( 310-717-7327
>>
>>      JCLUGO@xxxxxxxxx
>>
>> References
>>
>>      1.
>
https://paytrace.com/api/default.pay?parmlist=UN~demo123|PSWD~demo123|TERMS~
>
Y|METHOD~ProcessTranx|TRANXTYPE~Authorization|CC~4012881888818888|EXPMNTH~12
> |EXPYR~12|AMOUNT~1.00|CSC~999|BADDRESS~1234|BZIP~83852|INVOICE~8888|
>>      2. https://paytrace.com/api/default.pay
>>
>>
>>
>> ----------------------------------------------------------------------
>> - 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
> -----------------------------------------------------------------------


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