我正在尝试向 nodeJs 服务器发送 API 调用,但未调用 API。
StaticJsonDocument<200> doc;
doc["UID"] = tagID;
String payload;
serializeJson(doc, payload);
Serial.print(payload);
http.begin(wifiClient, serverUrl);
http.addHeader("Content-Type", "application/json");
int httpResponseCode = http.POST(payload);
// int httpResponseCode = http.POST("{\"UID\":\" 99 3C AB D5\"}");
Serial.print("HTTP Response code: ");
Serial.println(httpResponseCode);
// Free resources
http.end();
http.POST("{"UID":"99 3C AB D5"}");返回 -1 作为状态代码。 API 未被调用,因为服务器上的打印语句不起作用。