【发布时间】:2014-05-08 15:37:38
【问题描述】:
我正在尝试通过 Arduino 发布 json 数据。当我尝试使用此代码时。我将使用 QueryString 发送 json 数据。如果我尝试此代码,服务器会以错误的 QueryString 格式回答我。这意味着我已连接到服务器,服务器获取了我的数据。
if (client.connect(server, 80)) {
Serial.println("connected");
// Make a HTTP request:
client.println("POST /URL?query=jsondata HTTP/1.1");
client.println("Host: **.**.**.**");
client.println("Connection: close\r\nContent-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(PostData.length());
client.println();
client.println(PostData);
}
但我的主要计划是使用查询字符串发送我的 json 数据。如果我尝试此代码;
client.println("POST /URL?query={request:{Header:{Username:kullaniciAdi,Password:123456},Item:{Serial:ABC123QWE,Data:100, DateOn:23/11/1986 15:45:24}}} HTTP/1.1");
我收到 HTTP 错误 400。请求格式错误。
有人有什么想法吗?
【问题讨论】:
标签: json post arduino http-post