@@ -283,9 +283,11 @@ void AdafruitIO_Group::setLocation(double lat, double lon, double ele)
283
283
284
284
bool AdafruitIO_Group::exists ()
285
285
{
286
- _io->_http ->startRequest (_group_url, HTTP_METHOD_GET);
286
+ _io->_http ->beginRequest ();
287
+ _io->_http ->get (_group_url);
287
288
_io->_http ->sendHeader (" X-AIO-Key" , _io->_key );
288
289
_io->_http ->endRequest ();
290
+
289
291
int status = _io->_http ->responseStatusCode ();
290
292
_io->_http ->responseBody (); // needs to be read even if not used
291
293
return status == 200 ;
@@ -296,19 +298,27 @@ bool AdafruitIO_Group::create()
296
298
String body = " name=" ;
297
299
body += name;
298
300
299
- _io->_http ->startRequest (_create_url, HTTP_METHOD_POST);
300
- _io->_http ->sendHeader (HTTP_HEADER_CONTENT_TYPE, " application/x-www-form-urlencoded" );
301
- _io->_http ->sendHeader (HTTP_HEADER_CONTENT_LENGTH, body.length ());
301
+ _io->_http ->beginRequest ();
302
+ _io->_http ->post (_create_url);
303
+
304
+ _io->_http ->sendHeader (" Content-Type" , " application/x-www-form-urlencoded" );
305
+ _io->_http ->sendHeader (" Content-Length" , body.length ());
302
306
_io->_http ->sendHeader (" X-AIO-Key" , _io->_key );
307
+
308
+ // the following call to endRequest
309
+ // should be replaced by beginBody once the
310
+ // Arduino HTTP Client Library is updated
311
+ // _io->_http->beginBody();
312
+ _io->_http ->endRequest ();
313
+
314
+ _io->_http ->print (body);
303
315
_io->_http ->endRequest ();
304
- _io->_http ->write ((const byte*)body.c_str (), body.length ());
305
316
306
317
int status = _io->_http ->responseStatusCode ();
307
318
_io->_http ->responseBody (); // needs to be read even if not used
308
319
return status == 201 ;
309
320
}
310
321
311
-
312
322
void AdafruitIO_Group::_init ()
313
323
{
314
324
0 commit comments