POST problems

15 views
Skip to first unread message

Gareth Murfin

unread,
Jan 15, 2019, 10:10:20 PM1/15/19
to CodenameOne Discussions
Really not my week is it.... Im doing an ordinary post to my clients api, but it wont work. I send over the post params like this:

r.addArgument("id", "theirid");
r.addArgument("pw",     "theirpass");  
r.setPost(true);
NetworkManager.getInstance().addToQueue(r);

I have done this a million times in cn1 and never had a problem, but for some reason his API reports the id is "null"..  and wont let me login... this is the same code ive used on other apps with no issue.. I also tried sending json body etc, same error..

It works in postman using post params... we also made a website to test it, where it works fine too... Is there some weird thing happening with post in CN1? or something I forgot?    

Also if he switches to GET and we do it that way it does work... any ideas?? Also the url is httpS, is there anything special I need to do ?

Steve Hannah

unread,
Jan 15, 2019, 10:40:19 PM1/15/19
to codenameone...@googlegroups.com
What does the network monitor say?  You can look at the post body there.

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/46a89345-0d4a-4d54-be93-5f5947b5d3ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Steve Hannah
Software Developer
Codename One

Gareth Murfin

unread,
Jan 16, 2019, 1:26:05 AM1/16/19
to CodenameOne Discussions
Post body is empty in there. Should that show post parameters though ?


On Wednesday, January 16, 2019 at 11:40:19 AM UTC+8, Steve Hannah wrote:
What does the network monitor say?  You can look at the post body there.
On Tue, Jan 15, 2019 at 7:10 PM Gareth Murfin <gareth...@gmail.com> wrote:
Really not my week is it.... Im doing an ordinary post to my clients api, but it wont work. I send over the post params like this:

r.addArgument("id", "theirid");
r.addArgument("pw",     "theirpass");  
r.setPost(true);
NetworkManager.getInstance().addToQueue(r);

I have done this a million times in cn1 and never had a problem, but for some reason his API reports the id is "null"..  and wont let me login... this is the same code ive used on other apps with no issue.. I also tried sending json body etc, same error..

It works in postman using post params... we also made a website to test it, where it works fine too... Is there some weird thing happening with post in CN1? or something I forgot?    

Also if he switches to GET and we do it that way it does work... any ideas?? Also the url is httpS, is there anything special I need to do ?

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.

David Wafula

unread,
Jan 16, 2019, 1:35:51 AM1/16/19
to CodenameOne Discussions
I think it works with this order?

 r.setUrl(url); //this comes first ??
 r.setPost(true);
 r.addArgument("id", "theid);
 r.addArgument("pw", "thepws);


On Wed, Jan 16, 2019 at 8:26 AM Gareth Murfin <gareth...@gmail.com> wrote:
Post body is empty in there. Should that show post parameters though ?

On Wednesday, January 16, 2019 at 11:40:19 AM UTC+8, Steve Hannah wrote:
What does the network monitor say?  You can look at the post body there.
On Tue, Jan 15, 2019 at 7:10 PM Gareth Murfin <gareth...@gmail.com> wrote:
Really not my week is it.... Im doing an ordinary post to my clients api, but it wont work. I send over the post params like this:

r.addArgument("id", "theirid");
r.addArgument("pw",     "theirpass");  
r.setPost(true);
NetworkManager.getInstance().addToQueue(r);

I have done this a million times in cn1 and never had a problem, but for some reason his API reports the id is "null"..  and wont let me login... this is the same code ive used on other apps with no issue.. I also tried sending json body etc, same error..

It works in postman using post params... we also made a website to test it, where it works fine too... Is there some weird thing happening with post in CN1? or something I forgot?    

Also if he switches to GET and we do it that way it does work... any ideas?? Also the url is httpS, is there anything special I need to do ?

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
--
Steve Hannah
Software Developer
Codename One

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
David W

David Wafula

unread,
Jan 16, 2019, 1:39:04 AM1/16/19
to CodenameOne Discussions
Meant:

r.setPost  comes first before you do the arguments ?


--
David W

Gareth Murfin

unread,
Jan 16, 2019, 3:19:23 AM1/16/19
to CodenameOne Discussions
thanks david, never thought of that, though im sure this is code ive used before, but will try it out.


On Wednesday, January 16, 2019 at 2:39:04 PM UTC+8, davidwaf wrote:
Meant:

r.setPost  comes first before you do the arguments ?



On Wed, Jan 16, 2019 at 8:35 AM David Wafula <davi...@gmail.com> wrote:
I think it works with this order?

 r.setUrl(url); //this comes first ??
 r.setPost(true);
 r.addArgument("id", "theid);
 r.addArgument("pw", "thepws);


On Wed, Jan 16, 2019 at 8:26 AM Gareth Murfin <gareth...@gmail.com> wrote:
Post body is empty in there. Should that show post parameters though ?

On Wednesday, January 16, 2019 at 11:40:19 AM UTC+8, Steve Hannah wrote:
What does the network monitor say?  You can look at the post body there.
On Tue, Jan 15, 2019 at 7:10 PM Gareth Murfin <gareth...@gmail.com> wrote:
Really not my week is it.... Im doing an ordinary post to my clients api, but it wont work. I send over the post params like this:

r.addArgument("id", "theirid");
r.addArgument("pw",     "theirpass");  
r.setPost(true);
NetworkManager.getInstance().addToQueue(r);

I have done this a million times in cn1 and never had a problem, but for some reason his API reports the id is "null"..  and wont let me login... this is the same code ive used on other apps with no issue.. I also tried sending json body etc, same error..

It works in postman using post params... we also made a website to test it, where it works fine too... Is there some weird thing happening with post in CN1? or something I forgot?    

Also if he switches to GET and we do it that way it does work... any ideas?? Also the url is httpS, is there anything special I need to do ?

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.
--
Steve Hannah
Software Developer
Codename One

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.


--
David W


--
David W

Steve Hannah

unread,
Jan 16, 2019, 7:52:15 AM1/16/19
to codenameone...@googlegroups.com

Post body is empty in there. Should that show post parameters though ?

Yes it should show the post parameters in the request body.


Gareth Murfin

unread,
Jan 17, 2019, 4:54:49 PM1/17/19
to CodenameOne Discussions
thanks, nothing shows up in there, no idea, this code has worked on many apps for years. Can you verify it still works for you steve?

Shai Almog

unread,
Jan 17, 2019, 10:38:20 PM1/17/19
to CodenameOne Discussions
The order won't change anything because the call is useless. Had you invoked setPost(false) you would have gotten an exception but because the request is already a post request it doesn't do anything. Post body arrives just fine for my requests.
Reply all
Reply to author
Forward
0 new messages