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

http_url_post_raw and paypal nvp



Helli,
i am having a problem with using a webservice from Paypal.
If i post the url direct in a webbrowser, i get the correct data:

https://api-3t.paypal.com/nvp?USER=BENUTZER&PWD=PASSWORT&SIGNATURE=SIGNATUR&METHOD=GetTransactionDetails&Version=71.0&transactionID=TRANSAKTION


but  if  i  use http_url_post_raw, the server gives an answer with an
error, as if i do not send the corrent request.

this is the answer from the server taken from retdata after conversion:
TIMESTAMP=2011%2d09%2d23T12%3a29%3a54Z&CORRELATIONID=fef012b89dba&ACK=Failure&VERSION=71%2e0&BUILD=2133933&L_ERRORCODE0=10002&L_SHORTMESSAGE0=Security%20error&L_LONGMESSAGE0=Security%20header%20is%20not%20valid&L_SEVERITYCODE0=Error


here the source code:

      *
      * This performs the same example as EXAMPLE4, except that it
      * uses the "raw" versio of http_url_post(). The advantage is
      * that data is received directly into a variable in the program
      * instead of writing it to the IFS.
      *
      *
     H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')

     D/copy qrpglesrc,httpapi_h

     D incoming        PR            10I 0
     D   descriptor                  10I 0 value
     D   data                      8192A   options(*varsize)
     D   datalen                     10I 0 value

     D rc              s             10I 0
     D msg             s             52A
     D CRLF            C                   CONST(x'0d25')
     D data            S           1024A
     D postdata        S           1024A
     D tracknum        S             20A   inz('1Z12345E0390515214')
     D retdata         S          32766A
     D retlen          S             10I 0
     D nextpos         S             10I 0 inz(1)

     d $status         s              1A
     d $trid           s             19A
     d $ergebnis       s              1A

     c     *entry        plist
     c                   parm                    $status
     c                   parm                    $trid
     c                   parm                    $ergebnis
      *
     c                   eval      *inlr = *on

     C* OOh, let's track a package with UPS!
     C*
     C* FOR A BETTER EXAMPLE OF UPS PACKAGE TRACKING, SEE EXAMPLE16
     c                   eval      postdata = 'https://api-3t.paypal.com/nvp'
      *
     c                   eval      data = '?USER=BENUTZER' +
     c                             '&PWD=PASSWORT' +
     c                             '&SIGNATURE=SIGNATUR' +
     c                             '&METHOD=GetTransactionDetails' +
     c                             '&Version=71.0' +
     c                             '&transactionID=' +
     c                             $trid

     C**  The only diff between using HTTPS and using HTTP is
     C**  the URL that we pass.  It starts with 'https://'
     c                   eval      rc=http_url_post_raw(
     c                             postdata:
     c                              %addr(data): %len(%trimr(data)):
     c                              1: %paddr('INCOMING'))
     c                   if        rc <> 1
     c                   eval      msg = http_error
     c                   dsply                   msg
     c                   return
     c                   endif

     C* convert the data we just received to EBCDIC
     c                   if        retlen > 1
     c                   callp     http_xlate(retlen: retdata: TO_EBCDIC)
     c                   endif

     C* now the returned data is in the 'retdata' string.
     C*  run this program in debug and display retdata....  you'll see...
     c                   return


     P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P*  this procedure will receive the raw data received from UPS
     P*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
     P incoming        B
     D incoming        PI            10I 0
     D   descriptor                  10I 0 value
     D   data                      8192A   options(*varsize)
     D   datalen                     10I 0 value

     C* Make sure we don't overflow the string:
     c                   eval      retlen = (nextpos + datalen) - 1
     c                   if        retlen > %size(retdata)
     c                   eval      datalen=datalen-(retlen-%size(retdata))
     c                   endif

     C* If there is nothing to write, return THAT...
     c                   if        datalen < 1
     c                   return    0
     c                   endif

     C* Here we add any data sent to the end of our 'retdata' string:
     c                   eval      %subst(retdata: nextpos) =
     c                                %subst(data:1:datalen)
     c                   eval      nextpos = nextpos + datalen

     c* We always return the amount of data that we wrote.   Note
     C*  that if http-api sees that we didn't write as much data as
     C*  it sent us, it'll abort the process with an error message.
     c                   return    datalen
     P                 E





Mit freundlichen Grüssen
Jürgen Seifert
- Leiter EDV -

mailto: seifert@xxxxxxxxxxxxx
web: www.angelsport.de
Tel: 02591/950966
Fax: 02591/950965

Askari Sport GmbH
Hans-Böckler-Str. 7, 59348 Lüdinghausen, Deutschland
Registergericht: Amtsgericht Coesfeld, HRB 6840
Geschäftsführer: Paul Brüggemann, Heike Wagner, Rüdiger Walter

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