Skip to content

Instantly share code, notes, and snippets.

@theycallmeswift
Last active December 20, 2015 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theycallmeswift/6095051 to your computer and use it in GitHub Desktop.
Save theycallmeswift/6095051 to your computer and use it in GitHub Desktop.
BreakfastSerial Code Snippets
#include <Ethernet.h>
#include <SPI.h>
EthernetClient client;
String data = '{"foo":"bar"}';
void setup() {
Ethernet.begin({0x90,0xA2,0xDA,0x00,0x55,0x8D});
}
void loop() {
if (client.connect("www.someapi.com",80)) {
client.println("POST /api/v1/endpoints HTTP/1.1");
client.println("Host: www.someapi.com");
client.println("Content-Type: application/json");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
client.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment