How to do: setEntity() ?

11 views
Skip to first unread message

Gareth Murfin

unread,
Jan 9, 2018, 5:27:52 AM1/9/18
to CodenameOne Discussions
I have some android code I am porting to cn1, in my networking I do:

HttpPost httppost = new HttpPost(url);
httppost.setEntity(new StringEntity(s));

I dont recall why I use setEntity, but I am posting a snippet of json to the server, what is the equivalent way to do this in CN1?

Gareth Murfin

unread,
Jan 9, 2018, 7:58:05 AM1/9/18
to CodenameOne Discussions
Think I found it in some of my old code its something like this right?

final ConnectionRequest r = new ConnectionRequest() 
        {        
            @Override
             protected void buildRequestBody(OutputStream os) throws IOException 
             {  
                 _("/////////////////////////////buildRequestBody adding payload of:");
                 _("-->\n"+payload);
                os.write(payload.getBytes("UTF-8"));

Gareth Murfin

unread,
Jan 9, 2018, 9:12:32 AM1/9/18
to CodenameOne Discussions
Yes this works.
Reply all
Reply to author
Forward
0 new messages