【发布时间】:2018-06-10 02:37:15
【问题描述】:
我有一个带有 WebHook 的 Slack 频道设置,基本上我可以运行 POST 并向我的频道发送消息。在我的桌面上使用 HTTP 工具时一切正常,但我无法从 Arduino UNO + Ethernet Shield 发送 POST。
这是我的代码。是的,我正在分享我的 webHookURL,不用担心,这只是一个测试 :-)
String PostData = "{\"text\": \"Agora Vai\"}";
Serial.println(PostData);
client.println("POST /services/TAXFFU91T/BAXFMF8BF/LPH1b60RsQpOGvur2ZNn0zpz HTTP/1.1");
client.println("Host: hooks.slack.com");
client.println("User-Agent: Arduino/1.0");
client.println("Connection: close");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.print(PostData.length());
client.println("\n");
client.println(PostData);
client.println("");
我得到一个 HTTP 400:
HTTP/1.1 400 Bad Request
Server: CloudFront
Date: Sun, 10 Jun 2018 02:30:37 GMT
Content-Type: text/html
Content-Length: 556
Connection: close
X-Cache: Error from cloudfront
Via: 1.1 b7a41f8635d9e8e6499fbcc9612f2ec5.cloudfront.net (CloudFront)
X-Amz-Cf-Id: z8WMFOiFRe1nZnSzNbFdSIGriOhh0vv1TxbxFrkuZ9JUoPnssnBbrQ==
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>400 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
Slack 支持团队回答我,这可能是一个格式错误的 POST,但我看不出在哪里。
有什么想法吗?
【问题讨论】:
标签: http arduino http-headers