Problems with POST through HTTP.request #4917
Replies: 1 comment
-
Posted at 2017-06-26 by @gfwilliams That's odd... Could you have a go at adding a 'Content-Length' header? There are a few examples of POSTing data on the IoT services page: http://www.espruino.com/IoT+Services and you could have a go at modifying one of those? Posted at 2017-06-27 by davidhay OK - so I got the dweet one working OK, but still no luck with mine (including the content-length). Is there any way to see the actual request being made? The request function is never invoking the response callback, so would be nice to se what was on the wire... cheers Posted at 2017-06-27 by dave_irvine Change your host from Posted at 2017-06-27 by @gfwilliams Wow, nicely spotted @dave_irvine! :) You can add an error handler to see what's up with the connection as well if you want to: http://www.espruino.com/Internet#handling-errors Posted at 2017-06-27 by davidhay Nicely spotted indeed! All working now - thanks...
Posted at 2017-06-27 by @gfwilliams Was content-length required in the end? Or was it just the URL that @dave_irvine spotted? Posted at 2017-06-27 by davidhay It was the URL - adding the content-length didn't help... Posted at 2020-09-03 by user117414 hey mr @davidhay. I am trying your code out and I have replaced the host and wifi info with my own, but for some odd reason i am getting a code-6 message not found |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2017-06-26 by davidhay
Hi Guys - having issues getting an HTTP POST to work. Device is an espruino wifi, flashed to the latest version.
Here's the code:
The connection works OK and I also get the 'request sent' message, but nothing after that on the espruino, and no connection received by the server.
I've verified that the endpoint (which is a server of mine) is working OK (accepts a POST from a REST client), and HTTP.GET works fine (copied one of the examples). I'm doubtless doing something basic wrong, but not sure how to debug further...
Beta Was this translation helpful? Give feedback.
All reactions