Skip to content

Commit be713aa

Browse files
committed
update block http client calls
1 parent de055ce commit be713aa

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/blocks/AdafruitIO_Block.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,21 @@ bool AdafruitIO_Block::save()
7575
body += block_feeds;
7676
body += "}";
7777

78-
http->startRequest(url.c_str(), HTTP_METHOD_POST);
79-
http->sendHeader(HTTP_HEADER_CONTENT_TYPE, "application/json");
80-
http->sendHeader(HTTP_HEADER_CONTENT_LENGTH, body.length());
78+
http->beginRequest();
79+
http->post(url.c_str());
80+
81+
http->sendHeader("Content-Type", "application/json");
82+
http->sendHeader("Content-Length", body.length());
8183
http->sendHeader("X-AIO-Key", _dashboard->io()->_key);
84+
85+
// the following call to endRequest
86+
// should be replaced by beginBody once the
87+
// Arduino HTTP Client Library is updated
88+
// http->beginBody();
89+
http->endRequest();
90+
91+
http->print(body);
8292
http->endRequest();
83-
http->write((const byte*)body.c_str(), body.length());
8493

8594
int status = http->responseStatusCode();
8695
http->responseBody(); // needs to be read even if not used

0 commit comments

Comments
 (0)