Sending POST HTTPrequest with arguments

54 views
Skip to first unread message

mbmai...@gmail.com

unread,
Feb 13, 2014, 3:18:31 AM2/13/14
to codenameone...@googlegroups.com
    I want to send an HTTPRequest to my Web Server. When I use the GET Request, it works. But I want to use a POST Request, so I wrote the following code:


         req.setUrl("http://rv21.software.ee/changecustomer.json")


             req.setContentType("application/x-www-form-urlencoded");
             req.addArgument("session", session);
             req.addArgument("id", CurrentCustomer.ID);
             req.addArgument("custname",findTxtName().getText());
             req.addArgument("custnummer",findTxtNummer().getText());
             req.addArgument("custplz",findTxtPLZ().getText());
             req.addArgument("custstadt",findTxtOrt().getText());
             req.addArgument("custwebsite",findTxtHomepage().getText());
             System.out.println( req.getHttpMethod());
            
            
            
             InfiniteProgress prog = new InfiniteProgress();
             Dialog dlg = prog.showInifiniteBlocking();
             req.setDisposeOnCompletion(dlg);
             NetworkManager.getInstance().addToQueueAndWait(req);

The Server gets the POST Request, but not the arguments. Is there something missing in my code?
Please help me.

Shai Almog

unread,
Feb 13, 2014, 3:26:02 AM2/13/14
to codenameone...@googlegroups.com
Did you just set the method to post or are you using setPost(true)?
This should work seamlessly and we use this frequently.

mbmai...@gmail.com

unread,
Feb 13, 2014, 3:43:43 AM2/13/14
to codenameone...@googlegroups.com


On Thursday, February 13, 2014 9:26:02 AM UTC+1, Shai Almog wrote:
Did you just set the method to post or are you using setPost(true)?
This should work seamlessly and we use this frequently.

 I added this two line of codes and now it is working:
             req.setPost(true);
             req.setHttpMethod("POST");

Reply all
Reply to author
Forward
0 new messages