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

Re: first program help



Hello,

It would appear that the web site is expecting a GET request with 
parameters encoded into the URL, but you are sending a POST request with 
the parameters included in the POST data upload.

Try changing your HTTP_url_post() to HTTP_url_get() instead.  So the 
code reads more like this:

   C                   eval      Enc = http_url_encoder_new

   c                   callp     http_url_encoder_addvar_s( Enc
   c                                                      : 'u'
   c                                                      :'UserName')

   c                   callp     http_url_encoder_addvar_s( Enc
   c                                                      : 'p'
   c                                                      :'Password')

   c                   eval      URL = 'http://www.valuesms.com/log.php?'
   c                                 + http_url_encoder_getstr(Enc)

   c                   callp     http_debug(*ON)

   c                   eval      rc = http_url_get( URL
   C                                              : '/tmp/testpost.html')

Just make the 'URL' field a large VARYING field... maybe "1024A VARYING" 
or something like that.

Good luck


A. M. [Tony] Cusack wrote:
> Hello group,
> 
> I am attempting to get my first http program running without success.
> 
> Here is the web site php script I am trying to get to with the parameters
> shown 
> 
> http://www.valuesms.com/log.php?u=Username&p=Password 
> 
> if I go there from a web browser I expect to get a response of "400 Bad
> Request (login error)" which is what happens
> 
> However when I go there with the program below, I get a response of "400 Bad
> Request (incomplete data)" which I what I would get if I went to the web
> page with no parameters i.e. http://www.valuesms.com/log.php 
> 
> To me, this indicates that the parameters are not getting from my program to
> the php script on the web site, although I do see them in the debug output.
> 
> Below is my program & the debug output.
> 
> The program is basically a copy of EXAMPLE2
> 
> Hope someone can see the error & help me out.
> 
> Regards
> 
> Anthony
> 
> 
> Program
> 
>      H DFTACTGRP(*NO) ACTGRP(*NEW) BNDDIR('HTTPAPI')
> 
> 
>      D/copy qrpglesrc,httpapi_h
> 
>      D cmd             pr                  extpgm('QCMDEXC')
>      D  command                     200A   const
>      D  length                       15P 5 const
> 
>      D CRLF            C                   CONST(x'0D25')
>      D rc              s             10I 0
>      D msg             s             52A
> 
>      D Enc             s                   like(HTTP_URL_ENCODER)
>      D myPointer       s               *
>      D dataSize        s             10I 0
> 
> 
>      C                   eval      Enc = http_url_encoder_new
> 
>      c                   callp     http_url_encoder_addvar_s( Enc
>      c                                                      : 'u'
>      c                                                      : 'UserName')
> 
>      c                   callp     http_url_encoder_addvar_s( Enc
>      c                                                      : 'p'
>      c                                                      : 'Password')
> 
>      c                   callp     http_url_encoder_getptr( Enc
>      c                                                    : myPointer
>      c                                                    : dataSize )
> 
> 
>      c                   callp     http_debug(*ON)
> 
>      c                   eval      rc = http_url_post(
>      c                              'http://www.valuesms.com/log.php'
>      c                             : myPointer
>      c                             : dataSize
>      c                             : '/tmp/testpost.html' )
> 
>      c                   if        rc = 302
>      c                   eval      rc = http_url_get( http_redir_loc()
>      c                                          : '/tmp/testpost.html')
>      c                   endif
> 
>      c                   if        rc <> 1
>      c                   eval      msg = http_error
>      c                   dsply                   msg
>      c                   else
>      c                   callp     cmd('DSPF ''/tmp/testpost.html''': 200)
>      c                   endif
> 
>      c                   callp     http_url_encoder_free(Enc)
> 
>      c                   eval      *inlr = *on                       
-----------------------------------------------------------------------
This is the FTPAPI mailing list.  To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------