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

Re: Problem with http_url_encoder_addvar or me?



Hi Derik,

The purpose of the http_url_encoder_xxxx routines is to convert chars 
that aren't legal in a URL to their hex equivalents.  If you don't want 
to do that, perhaps you shouldn't be calling the http_url_encoder routines?!

To see the entire POST transaction, create a debug log, as described in 
the 2nd half of the following page:
http://www.scottklement.com/httpapi/beta



Derik Blocker wrote:
>    Is there some way to do http_url_encoder_addvar without having it
>    change the special characters to hex?  I think I need it to be sent in
>    the format as it was when passed into the pgm.  Also, is there a way
>    to see the entire HTTP_POST message being passed to the remote system?
> 
>      *
>      * From: "Derik Blocker" <[1]blockerd@xxxxxxxxxxxxxxx> 
>      * To: <[2]ftpapi@xxxxxxxxxxxxxxxxxxxxxx> 
>      * Subject: Re: Problem with http_url_encoder_addvar or me? 
>      * Date: Wed, 8 Apr 2009 16:20:54 -0500 
>      _________________________________________________________________
> 
>    Hi Scott,
> 
> 
> 
>    The +2 was a failed attempt to try something from one of the examples
>    I saw in the archives.  I was getting the same results without the +2
>    except that the beginning Hex codes were not stripped off.
> 
> 
>      * From: Scott Klement <[3]sk@xxxxxxxxxxxxxxxx>
>      * To: HTTPAPI and FTPAPI Projects <[4]ftpapi@xxxxxxxxxxxxxxxxxxxxxx>
>      * Subject: Re: Problem with http_url_encoder_addvar or me?
>      * Date: Wed, 08 Apr 2009 14:51:31 -0500
>   __________________________________________________________________________
> hi Derik,
> 
>>    c                   callp     http_url_encoder_addvar(enc:
>>    C                             'request':dest+2:%len(%trimr(data))
> 
> Why are you adding 2 to 'dest'?  The reason I ask, you seem to be
> missing the first 2 characters of your XML document in the encoded data.
>   And, you're doing dest+2, which tells it "skip the first two bytes".  S
> 
> So I wonder why you're doing that?  Does 'dest' point to a VARYING
> field?  If so, why are you trimming the data when calculating the length?
> 
>  I am having a problem posting and not sure why.  I am passing the
>    following string into my pgm via a net.data table:
> 
>    <?xml version="1.0" encoding="UTF-8" ?>
>    <PaymentBatch password="xxxxxx" accountID="999">
>     <Payment sequenceID="1">
>      <CreditCardPayment>
>       <Item>
>        <NewItem>
>         <Amount>87.00</Amount>
>         <ItemTitle>Test reg item</ItemTitle>
>         <ItemDescription>Sample Item for registration</ItemDescription>
>         <ItemCompany>742</ItemCompany>
>        </NewItem>
>       </Item>
>       <Payor>
>        <Name>
>         <IndividualName>
>          <FirstName>John</FirstName>
>          <LastName>Smith</LastName>
>         </IndividualName>
>        </Name>
>        <Email>jsmith@xxxxxxxx</Email>
>        <StreetAddress1>1592 Elm Street</StreetAddress1>
>        <StreetAddress2>Freddy Suite</StreetAddress2>
>        <City>New York</City>
>        <State>New York</State>
>        <Zip>33333</Zip>
>        <SSN>7121</SSN>
>       </Payor>
>       <CreditCardAccount>
>        <CardType>Mastercard</CardType>
>        <CardNumber>43219999999999999</CardNumber>
>        <ExpirationMonth>09</ExpirationMonth>
>        <ExpirationYear>2009</ExpirationYear>
>        <SecurityCode>123</SecurityCode>
>        <UseAVS>False</UseAVS>
>       </CreditCardAccount>
>       <StudentName>Jennifer Smith</StudentName>
>      </CreditCardPayment>
>     </Payment>
>    </PaymentBatch>
> 
>    I need to post that string in a form-variable called "request" so I do
>    the following in my code:
> 
>    C                   eval      rc = dtw_table_GetV(table1:
>    C                                  dest:1:1)
>    C                   eval      data = %str(dest)
> 
>    C                   eval      enc = HTTP_url_encoder_new()
>    c                   callp     http_url_encoder_addvar(enc:
>    C                             'request':dest+2:%len(%trimr(data))
>    c                   callp     http_url_encoder_getptr(enc: encd: size)
>    c                   eval      rc=http_url_post_raw(
>    c                             '[5]https://www.mypaynetapps.com' +
>    c                             '/gateway.php':
>    c                              encd: size:
>    c                              1: %paddr('INCOMING'))
>    c                   callp     http_url_encoder_free(enc)
> 
>    after calling http_url_encoder_addvar the content of encd is:
> 
>    request=xml+version%3D%221.0%22+encoding%3D%22UTF-8%22+%3F%3E%0D%0A%3C
>    PaymentBatch+password%3D%22xxxxxxxxx%22+accountID%3D%22999%22%3E%0D%0A
>    +%3CPayment+sequenceID%3D%221%22%3E%0D%0A++%3CCreditCardPayment%3E%0D%
>    0A+++%3CItem%3E%0D%0A++++%3CNewItem%3E%0D%0A+++++%3CAmount%3E87.00%3C%
>    2FAmount%3E%0D%0A+++++%3CItemTitle%3ETest+reg+item%3C%2FItemTitle%3E%0
>    D%0A+++++%3CItemDescription%3ESample+Item+for+registration%3C%2FItemDe
>    scription%3E%0D%0A+++++%3CItemCompany%3E742%3C%2FItemCompany%3E%0D%0A+
>    +++%3C%2FNewItem%3E%0D%0A+++%3C%2FItem%3E%0D%0A+++%3CPayor%3E%0D%0A+++
>    +%3CName%3E%0D%0A+++++%3CIndividualName%3E%0D%0A++++++%3CFirstName%3EJ
>    ohn%3C%2FFirstName%3E%0D%0A++++++%3CLastName%3ESmith%3C%2FLastName%3E%
>    0D%0A+++++%3C%2FIndividualName%3E%0D%0A++++%3C%2FName%3E%0D%0A++++%3CE
>    mail%3Ejsmith%40mail.com%3C%2FEmail%3E%0D%0A++++%3CStreetAddress1%3E15
>    92+Elm+Street%3C%2FStreetAddress1%3E%0D%0A++++%3CStreetAddress2%3EFred
>    dy+Suite%3C%2FStreetAddress2%3E%0D%0A++++%3CCity%3ENew+York%3C%2FCity%
>    3E%0D%0A++++%3CState%3ENew+York%3C%2FState%3E%0D%0A++++%3CZip%3E33333%
>    3C%2FZip%3E%0D%0A++++%3CSSN%3E7121%3C%2FSSN%3E%0D%0A+++%3C%2FPayor%3E%
>    0D%0A+++%3CCreditCardAccount%3E%0D%0A++++%3CCardType%3EMastercard%3C%2
>    FCardType%3E%0D%0A++++%3CCardNumber%3E4321999999999999%3C%2FCardNumber
>    %3E%0D%0A++++%3CExpirationMonth%3E09%3C%2FExpirationMonth%3E%0D%0A++++
>    %3CExpirationYear%3E2009%3C%2FExpirationYear%3E%0D%0A++++%3CSecurityCo
>    de%3E123%3C%2FSecurityCode%3E%0D%0A++++%3CUseAVS%3EFalse%3C%2FUseAVS%3
>    E%0D%0A+++%3C%2FCreditCardAccount%3E%0D%0A+++%3CStudentName%3EJennifer
>    +Smith%3C%2FStudentName%3E%0D%0A++%3C%2FCreditCardPayment%3E%0D%0A+%3C
>    %2FPayment%3E%0D%0A%3C%2FPaymentBatch%3E%0D%0A%00%00
> 
>    and the response I get after the post is
> 
>    <ErrorList>
>        <Error>
>          <ErrorCode>1</ErrorCode>
>          <ErrorDescription>HTTP_POST is invalid</ErrorDescription>
>        </Error>
>      </ErrorList>
> 
>    Is the HTTP_POST invalid because all the special characters have been
>    converted to hex or am I doing something else wrong?
> 
> References
> 
>    1. mailto:blockerd@xxxxxxxxxxxxx
>    2. mailto:ftpapi@xxxxxxxxxxxxx
>    3. mailto:sk@xxxxxxxxxxxxx
>    4. mailto:ftpapi@xxxxxxxxxxxxx
>    5. https://www.mypaynetapps.com/
> 
> 
> 
> ------------------------------------------------------------------------
> 
> -----------------------------------------------------------------------
> 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
-----------------------------------------------------------------------