http发布请求中的错误

时间:2018-08-11 14:40:06

标签: http post request esp32

我正在尝试使用ESP32芯片通过发布请求来发布文件。

这是我的代码:

client.println("POST /t/7heku-1533923988/post HTTP/1.1");
client.println("Host: ptsv2.com");
client.println("Content-type: multi-part/form-data; boundary=Aa6b74");
client.println("Content-Length:118 ");
client.println();
client.println("--Aa6b74");
client.println("Content-Disposition: form-data; name=\"files\"; filename=\"myfile.txt\"");
client.println("Content-Type: text/plain");
client.println("test");
client.println("--Aa6b74");
client.println();

我正在使用ptsv2.com测试代码

返回码为200

我在洗手间上收到​​了请求,但没有收到文件,而是在帖子正文部分。

您能帮助我更正我的帖子请求吗? 谢谢。 F。

[编辑] 经过一番举动之后,我有了这个剧团:

client.print("POST /t/7heku-1533923988/post HTTP/1.0\r\n");
client.print("Host: ptsv2.com\r\n");
client.print("Content-type: multipart/form-data; boundary=Aa6b74\r\n");
client.print("Content-Length:125\r\n");
client.print("\r\n");
client.print("--Aa6b74\r\n");
client.print("Content-Disposition: form-data; name=\"files\"; filename=\"myfile.txt\"\r\n");
client.print("Content-Type: text/plain\r\n");
client.print("\r\n");
client.print("test");
client.print("--Aa6b74--\r\n");
client.print("\r\n");

代码更好,但仍然存在错误500。 F。

0 个答案:

没有答案