HTTP POST error message

Discussion in 'Questions (Windows Mobile)' started by miataman, Jun 11, 2008.

  1. miataman

    miataman Member Licensed User

    Hi,
    My program on the device display error during the request http :
    "An error message cannot
    be displayed because an
    optional resource assembly
    containing it cannot be
    found
    Continue?"


    (On the desktop it's OK no display error).

    My device under framework 2
    My project included objects ->
    Request:Webrequest
    Response:Webresponse

    my code :

    Response.new1
    Request.new1("http://wwwmyserver.com/upload.php?lat="&lat)
    Response.value=Request.Getresponse
    Res=Response.GetString
    Response.close

    thanks for help !
    stef
    :confused:
     
  2. agraham

    agraham Expert Licensed User

  3. miataman

    miataman Member Licensed User

    thanks Agraham

    my code for request http does not work :

    error An unexpected error occurred on a send
    continue?

    i'm checking....
     
  4. miataman

    miataman Member Licensed User

    always this error ! I don't understand :sign0085:
     
  5. agraham

    agraham Expert Licensed User

  6. TWELVE

    TWELVE Active Member Licensed User

    - He might wanna try a different server to exclude issues with a particular server.

    - different headers might be used for troubleshooting ( TRACE header for example would instruct the server to return the packets you sent to it).
    In case of issues with the http i would not start with POST, because that's the most difficult.Instead he should try a GET first to see how the server answers.

    - a network sniffer like WireShark might be used to figure out where the problem is very quickly - if one is familar with the usage of these tools.
    For me a sniffer is the first choice because i can see what's going on there immediatly.


    KeepAlive is integral part of the HTTP1.1 protocol.Therefore it is always enabled with HTTP 1.1, in contrast to 1.0, where the KeepAlive had to be enabled explicitly.Most servers support 1.1, so this is certainly not the cause of the issue.

    As i already said above, POST is not a good point to start with.Once a GET is working, this would be the proof that the routines work in general and the internet connection is ok.One could then proceed to test with POST headers.

    From my personal experience ( i also do a lot with these POSTs on the device)
    i would say, the error message mean, there is either a problem with the internet connection itself, the server connection ( does not accept the connection) or the DNS name resolution.

    I also use an errorhandler in my http send routine and whenever the errorhandler traps an error this means i do not have established an internet connection.Therefore i use this as indicator whether the connection is there or not ( due to lack of description of the error - i do not use your new library yet which returns descriptions ...;-) )


    kind regards

    TWELVE
     
    Last edited: Jun 12, 2008
  7. kawawong

    kawawong Member Licensed User

    Hi, TWELVE,

    Can you share some routine of using POST method? I want to submit some data to the web server, and the string is very large and cannot use the GET method (it works).

    I am looking for code snippet for doing this using http.dll.

    For example, i want to submit two set of text with name a and b. In the server side, I have a php script which use $_POST['a'] and $_POST['b'] to read these 2 data. I am now have problem of how to pass these two parameter in basic4ppc.

    Tks in advance.

    Cheers.
    Kawawong
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    You will need something like:
    Code:
    Sub Globals
    Dim buffer(0As byte
    End Sub
    Sub App_Start
        
    bit.New1 'bit is a Bitwise object
        postdate
    End Sub
    Sub PostDate
        Response.New1
        Request.New1(
    "http://www...")
        request.ContentType = 
    "application/x-www-form-urlencoded"
        request.Method = 
    "POST"
        writer.New1(request.GetStream,
    false)
        s = 
    "a=value1&b=23"
        buffer() = 
    bit.StringToBytes(s,0,StrLength(s))
        writer.WriteBytes(buffer())
        response.Value = request.GetResponse
        
    Msgbox(response.GetString)
        response.Close
    End Sub
     
  9. Cableguy

    Cableguy Expert Licensed User

    If this code is correct, the then error is a simple dot(.) missing after www....
     
  10. kawawong

    kawawong Member Licensed User

    Tks.

    Since I have a large text required to post to the server, is there any function like

    urlencode

    to encode the text first before POSTing it?

    :sign0085: ^_^
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    There is no built in function like urlencode in Basic4ppc.
    I think that for "simple" texts you could just use StrReplace to replace spaces, end of lines and maybe some other characters.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice