Hello!
I need your help with a project of mine:
the server is domoticz ( using basic authentication with user:111 and pass:111) - installed on windows 10
the ip address is: 192.168.2.122 and port 8080.
if i use this link in browser all work perfect : 111:111@192.168.2.122:8080/json.htm?type=command¶m=udevice&idx=3&nvalue=0&svalue=79
i tried this code, on nodemcu v3 ( the base64 library didn`t work so i use the conversion for user and password)
#include <ESP8266WiFi.h>
#include <Base64.h>
const char* ssid = "*****";
const char* password = "*****";
char uname[] = "111:111";
char unameenc[40];
_const char* host = "192.168.2.122"; _
const int httpPort = 8080;
void setup() {
- Serial.begin(115200);*
- delay(10);*
- WiFi.begin(ssid, password);*
}
void loop() { - WiFiClient client;*
- if (!client.connect(host, httpPort)) {*
- Serial.println("connection failed");*
- setup();*
} - String url = "/json.htm?type=command¶m=udevice&idx=3&nvalue=0&svalue=29";*
- client.print(String("POST ") + url + " HTTP/1.1\r\n" +*
- "Host: " + host + "\r\n" +*
- "Connection: close\r\n" +*
- "Authorization: Basic " + "MTExOjExMQ==" + " \r\n" +*
- "Content-Length: 0\r\n" +*
- "\r\n"*
- );*
- delay(10);*
}
this is the output of nodemcu:
connecting to 192.168.2.122
Requesting URL: /json.htm?type=command¶m=udevice&idx=3&nvalue=0&svalue=29
closing connection
this is the imput of domoticz:
Failed authentication attempt domoticz
Any ideas? tx a lot