Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By d2abhilash
#76367 Hi,
I am creating a webserver with the nodemcu. I want to send values to the server through http requests. I have successfully created the server and make http requests using fiddler on windows.
On the nodemcu side, I am unable to parse the arguments recieved because random characters are added to the start of every arg name and value like so
Arg no 0 = ⸮uname : ⸮MyUname

Initially I worked around by creating a function the strips one character at the start and then perform matching. It worked for a while, but suddenly after a few more code flashes on the nodemcu, the number of characters increased to 2. I realized I need to find a solid solution to this problem.

Here is my code.

Code: Select allESP8266WebServer server(82);
char *DEFAULT_PWD = "MyConnPwd";

void setup() {

void loop() {

void startServer(char *ssid, char *password){ 
    WiFi.softAP(ssid, password);
    IPAddress myIP = WiFi.softAPIP();
    server.on("/update", updateDeviceConfig);

bool updateDeviceConfig(){
  if (!server.hasArg("uname") || !server.hasArg("pwd")){ //Check if parameters received
      server.send(400, "application/json", "{\"error\" : 0}");
      return false;

   saveConfig(server.arg("uname"), server.arg("pwd"));
   return true;

updateDeviceConfig() always returns false. Here is the request I make from fiddler on windows.

Code: Select allPOST HTTP/1.1
User-Agent: Fiddler
Content-Length: 0

I printed out the args and their values using the following function

Code: Select allvoid handleGenericArgs() { //Handler
  String message = "Number of args received:";
  message += server.args();            //Get number of parameters
  message += "\n";                            //Add a new line
  for (int i = 0; i < server.args(); i++) {
    message += "Arg no " + (String)i + " = ";   //Include the current iteration value
    message += server.argName(i) + " : ";     //Get the name of the parameter
    message += server.arg(i) + "\n";              //Get the value of the parameter
  server.send(200, "text/plain", message);       //Response to the HTTP request

The response received is

Number of args received:2
Arg no 0 = ⸮⸮uname : ⸮⸮MyUname
Arg no 1 = ⸮⸮pwd : ⸮⸮MyPwd

Every item in the request is appended with ⸮⸮ at the start. Here's the output from the serial monitor.

Code: Select allNew client
method: ⸮⸮POST url: /update search: uname=MyUname&pwd=MyPwd
headerName: ⸮⸮User-Agent
headerValue: Fiddler
headerName: ⸮⸮Host
headerName: ⸮⸮Content-Length
headerValue: 0
:c0 1, 119
args: uname=MyUname&pwd=MyPwd
args count: 2
pos 0=@ 5 &@ 16
arg 0 key: ⸮⸮uname value: ⸮⸮MyUname
pos 17=@ 20 &@ -1
arg 1 key: ⸮⸮pwd value: ⸮⸮MyPwd
args count: 2
Request: /update
 Arguments: uname=MyUname&pwd=MyPwd
Handle Details

Any idea what could be the reason for this? Is there something in the string.h library that is messing things up? This problem is really bugging me. Thanks in advance for the help!