×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jul 2006
    Posts
    19

    Unhappy HTTP symbian example - post not working

    Hi I have compiled HTTP symbian example app for S60 3rd edition.
    I have no problems with get requests (I can send them and they reach server) but when I am trying to send POST reguest I am getting
    Error - 7334 (that means empty body)

    but actually I am filing the body
    I invoke function from symbian HTTP example in this manner:

    <code> iClient->IssueHTTPPostL(someAdrressThatIsOK,_L8("text/plain"),_L8("someparameter1=lala"));
    </code>

    Am I doing sth wrong here ? Does anyone has a working example of HTTP post ??


    The IssueHTTPPostL function from the symbian examples looks like this:
    <code>

    void CWebClientEngine::IssueHTTPPostL(const TDesC8& aUri,
    const TDesC8& aContentType,
    const TDesC8& aBody)
    {
    // Parse string to URI
    TUriParser8 uri;
    uri.Parse(aUri);

    // Copy data to be posted into member variable; iPostData is used later in
    // methods inherited from MHTTPDataSupplier.
    delete iPostData;
    iPostData = aBody.AllocL();

    // Get request method string for HTTP POST
    RStringF method = iSession.StringPool().StringF(HTTP::EPOST,
    RHTTPSession::GetTable());

    // Open transaction with previous method and parsed uri. This class will
    // receive transaction events in MHFRunL and MHFRunError.
    iTransaction = iSession.OpenTransactionL(uri, *this, method);

    // Set headers for request; user agent, accepted content type and body's
    // content type.
    RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
    SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
    SetHeaderL(hdr, HTTP::EAccept, KAccept);
    SetHeaderL(hdr, HTTP::EContentType, aContentType);

    // Set this class as an data supplier. Inherited MHTTPDataSupplier methods
    // are called when framework needs to send body data.

    /*
    MHTTPDataSupplier* dataSupplier = this;
    iTransaction.Request().SetBody(*dataSupplier);
    */
    // Submit the transaction. After this the framework will give transaction
    // events via MHFRunL and MHFRunError.
    iTransaction.SubmitL();

    iRunning = ETrue;
    _LIT(KConnecting,"Connecting post...");
    iObserver.ClientEvent(KConnecting);
    }

    </code>

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    34

    Re: HTTP symbian example - post not working

    Hi tomasz.florczak,

    The exampleclient at EPOCROOT\Examples\AppProts\exampleclient is working in both the cases GET/POST.

    In case of POST we have to set the content type to application/x-www-form-urlencoded see SDK documentation http://www.symbian.com/developer/tec...oderClass.html

    So, I think iClient->IssueHTTPPostL(someAdrressThatIsOK,_L8("application/x-www-form-urlencoded"),_L8("someparameter1=lala"));

    may also work.

    Giri.

  3. #3
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    Re: HTTP symbian example - post not working

    multipart/form-data; boundary=AaB03x.

  4. #4
    Registered User
    Join Date
    Jul 2010
    Posts
    2

    Re: HTTP symbian example - post not working

    I also have the same problem.I want to post image,May I have a chat,My QQ is 441024479 in China.

  5. #5
    Registered User
    Join Date
    Jun 2011
    Posts
    8

    Re: HTTP symbian example - post not working

    Hi tomasz.florczak
    Can you please guide me how to send a simple servlet post get request using C++ Symbian SDK 60 5th edition? I am able topost and get my request/response in j2me but the same i am unable to do in C++ I think it is more complicated then I expected.. Please guide how this can be done.. will be really greatful if you can post some example code .. My j2me code is as below


    HttpConnection hc = null;
    InputStream in = null;
    OutputStream out = null;

    try
    {
    String message = "";
    String url = "http://192.168.17.15:29159/WebApplication1/RegisterFriend?mobile="+input1.getString()+"&uname="+input2.getString()+"";
    hc = (HttpConnection)Connector.open(url);
    hc.setRequestMethod(HttpConnection.POST);
    hc.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    hc.setRequestProperty("Content-Length",Integer.toString(message.length()));
    out = hc.openOutputStream();
    out.write(message.getBytes());
    in = hc.openInputStream();
    int length = (int)hc.getLength();
    byte[] data = new byte[length];
    in.read(data);
    String response = new String(data);
    StringItem stringItem = new StringItem(null, response);
    LocateFriendForm.append(stringItem);
    LocateFriendForm.setTitle("Done.");
    }
    catch (IOException ioe) {
    StringItem stringItem = new StringItem(null, ioe.toString());
    LocateFriendForm.append(stringItem);
    LocateFriendForm.setTitle("Done.");
    }
    finally {
    try {
    if (out != null) out.close();
    if (in != null) in.close();
    if (hc != null) hc.close();
    }
    catch (IOException ioe) {}

    }

Similar Threads

  1. Using HTTP POST & Nokia 6600 to upload octet stream to server
    By ssandor in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-09-19, 11:00
  2. Http Post
    By maimonides in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2005-05-17, 07:49
  3. HTTP POST not working for Nokia 3300
    By meyy6 in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-02-03, 19:05
  4. Error while sending HTTP Post Request
    By bhonsle in forum Mobile Java Networking & Messaging & Security
    Replies: 2
    Last Post: 2004-01-11, 16:28
  5. http post problem, series 60
    By tbabben in forum Mobile Java Networking & Messaging & Security
    Replies: 6
    Last Post: 2003-10-20, 06:30

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •