Jump to content









Photo

Pulling data using arduino


  • Please log in to reply
1 reply to this topic

#1 Aquaman

Aquaman

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 24 April 2016 - 09:31 PM

I am currently using an arduino to post data to the Carriots server, and that side of things is working properly.

 

I have also set up a simple webpage that is able to pull that data from the stream.

 

What I would really like to do is have the arduino pull the data instead of javascript, so that eventually I could have multiple arduinos both posting and pulling data. 

 

Could anyone provide some sample code? I feel like it should be a pretty simple GET request, but I'm not sure how to get the headers right with the apikey. 

 

Thanks
 



#2 Aquaman

Aquaman

    Newbie

  • Members
  • Pip
  • 2 posts

Posted 28 April 2016 - 03:12 AM

Here's the answer I was looking for:

 

  if (client.connect(server, 80)) {   // If there's a successful connection
    client.println("GET /devices/"+DEVICE+"/streams/ HTTP/1.1");
    client.println("Host: api.carriots.com");
    client.println("Accept: application/json");
    client.println("User-Agent: Arduino-Carriots");
    client.println("Content-Type: application/json");
    client.print("carriots.apikey: ");
    client.println(APIKEY);
    client.println("Connection: close");
    client.println();
  }





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users