Comments on: ESP8266 NodeMCU HTTP GET and HTTP POST with Arduino IDE (JSON, URL Encoded, Text) https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Sun, 10 Nov 2024 20:32:13 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Jack https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-981961 Sun, 10 Nov 2024 20:32:13 +0000 https://randomnerdtutorials.com/?p=95691#comment-981961 Hi
I found this post (and some other) after looking for a solution to use an external webservice with POST, thanks to Rui for all these explainations.
Right now I’m stuck on a slight problem. with an ESP8266 I send data (the Mac Address of the esp8266) on a POST webservice (external web site), and this site returns me a status 200 and a JSON file which contains a token related to the transaction of which here is an example generated by the web service:
{ “token”: “39387e8a-6afe-40a7-b1dc-043173689112” }
I can’t get this value, I only get the http:200
with this line of code :
// HTTP request with a content type: application/json, use the following:
https.addHeader(“Content-Type”, “application/json”);
int httpResponseCode = https.POST(json);
Serial.println(httpResponseCode);

Do you have any ideas? 2 or 3 lines of code to get me started?
Thanks a lot!

]]>
By: George Pantel https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-872732 Sat, 18 Nov 2023 12:28:28 +0000 https://randomnerdtutorials.com/?p=95691#comment-872732 Hello. I have the following setup. An arduino mega conected to a ESP8266 ESP-01. I’m trying to replicate first guide but I get the the following error: ESP8266WiFi.h: No such file or directory. Can you advise me on what should I do to get it to work on my setup?

]]>
By: AJAY https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-842385 Fri, 23 Jun 2023 06:19:25 +0000 https://randomnerdtutorials.com/?p=95691#comment-842385 Hi,
No need to enter API key( Inside body )in HTTP post with JASON object right? we can give only sensor data also?

]]>
By: Sara Santos https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-826848 Sat, 25 Mar 2023 11:15:06 +0000 https://randomnerdtutorials.com/?p=95691#comment-826848 In reply to AJITH KUMAR.

Hi.
Maybe you need to try HTTPS requests instead.
See this tutorial to learn how to make HTTPS requests with the ESP8266: https://randomnerdtutorials.com/esp8266-nodemcu-https-requests/
Regards,
Sara

]]>
By: AJITH KUMAR https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-826586 Thu, 23 Mar 2023 08:46:16 +0000 https://randomnerdtutorials.com/?p=95691#comment-826586 I have used express.js as a backend server to respond to the request created by the Arduino ESP8266 ,
here is the code for express.js: filename:”server.js”
const express = require(‘express’);
const app = express();

// Serve static files
app.use(express.static(‘public’));

// Handle incoming HTTP requests
app.post(‘/update-sensor’, (req, res) => {
console.log(‘Received request:’, req.query.state);
console.log(‘posted’);
res.status(200).send()
});

app.listen(5000, () => {
console.log(‘Server started on port 3000’);
});

it is hosted in ngrok with https protocol, but it throws error like this:
……………
Connected to WiFi network with IP Address: 172.29.107.223
Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.
HTTP Response code: -5
HTTP Response code: -5
HTTP Response code: -5
HTTP Response code: -5
and so on….

]]>
By: Aditya Pawar https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-812448 Mon, 23 Jan 2023 14:11:47 +0000 https://randomnerdtutorials.com/?p=95691#comment-812448 In reply to Sara Santos.

Thank you for your reply first we need to establish connection with mysql database and pass a value generated from esp32 through php file with a http post request.

]]>
By: Sara Santos https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-812434 Mon, 23 Jan 2023 12:37:53 +0000 https://randomnerdtutorials.com/?p=95691#comment-812434 In reply to Olle Hiling.

Hi.
You’ll need to adjust your code to make an HTTPS request instead.
You can take a look at this tutorial to learn how to make HTTPS requests with the ESP8266:https://randomnerdtutorials.com/esp8266-nodemcu-https-requests/
Regards,
Sara

]]>
By: Olle Hiling https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-812190 Sun, 22 Jan 2023 15:16:39 +0000 https://randomnerdtutorials.com/?p=95691#comment-812190 Hell0, Im trying to use your code for retrivieing the Json file on this webpage
elprisetjustnu.se/api/v1/prices/2023/01-22_SE3.jsonhttps://www.elprisetjustnu.se/api/v1/prices/2023/01-22_SE3.json
but i cant get it to work. I think the problem might be that it is an https page. Any ideas?
The data is generated from this Swedish page elprisetjustnu.se/elpris-api,
to get a fresh data page press the green box with the text “Testa själv” sorry for the swedish page

]]>
By: Emre https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-789048 Thu, 06 Oct 2022 09:00:12 +0000 https://randomnerdtutorials.com/?p=95691#comment-789048 This is nice, but I want to clarify something:
“http://192.168.1.106:1880/update-sensor” is not the server name.

192.168.1.106 is the name (in this case, already resolved as the IP address)
http is the protocol.
1880 is the port
/update-sensor is the path.

structure of a url is:
“{protocol}://{server_name_or_ip}{path}”
or
“{protocol}://{server_name_or_ip}:{port}{path}”

]]>
By: Antonio Poiani https://randomnerdtutorials.com/esp8266-nodemcu-http-get-post-arduino/#comment-775288 Fri, 12 Aug 2022 22:59:32 +0000 https://randomnerdtutorials.com/?p=95691#comment-775288 I just found my mistake! Your code is flawless! I mistyped the server details. I have included the path to the area where the data is stored instead of stopping where the data is received. Working well now! Tks!

]]>