@@ -283,9 +283,11 @@ void AdafruitIO_Group::setLocation(double lat, double lon, double ele)
283283
284284bool AdafruitIO_Group::exists ()
285285{
286- _io->_http ->startRequest (_group_url, HTTP_METHOD_GET);
286+ _io->_http ->beginRequest ();
287+ _io->_http ->get (_group_url);
287288 _io->_http ->sendHeader (" X-AIO-Key" , _io->_key );
288289 _io->_http ->endRequest ();
290+
289291 int status = _io->_http ->responseStatusCode ();
290292 _io->_http ->responseBody (); // needs to be read even if not used
291293 return status == 200 ;
@@ -296,19 +298,27 @@ bool AdafruitIO_Group::create()
296298 String body = " name=" ;
297299 body += name;
298300
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 ());
302306 _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);
303315 _io->_http ->endRequest ();
304- _io->_http ->write ((const byte*)body.c_str (), body.length ());
305316
306317 int status = _io->_http ->responseStatusCode ();
307318 _io->_http ->responseBody (); // needs to be read even if not used
308319 return status == 201 ;
309320}
310321
311-
312322void AdafruitIO_Group::_init ()
313323{
314324
0 commit comments