title: Arduino Uno POST Data using ENC28J60
body: <p>I'm tried do a HTTP POST to my php server, but i got a wrong request in server log:</p>
  
  <pre><code> :192.168.1.15 - - [12/Mar/2018:17:46:16 -0300] "POST \xa9\x020\x91\xa7\x020\x93\xa9\x02 \x93\xa7\x02.\xea2\xe0\xa2\xeb\xb2\xe0\xf9\x01B\x91\x84\x0f\x91\x1dN\x91\x8c\x93f#\x11\xf0@\x83\x01\xc0\x10\x82\x89/\x99'D\xe0N\x0fB\x13\xf0\xcf\x10\x92\xb6\x02\x10\x92\xb7\x02\x80\xe5\x80\x93\xb2\x02\b\x95\x0f\x93\x1f\x93\xcf\x93\xdf\x93p\xe0lW}O!0!\xf4\x8a\x01\x07_\x1fO\x0c\xc0\"09\xf0 HTTP/1.0" 400 471 "-" "-"
  </code></pre>
  
  <p>If a try using HTTP GET, a got sucess and a got a expected request in sever log:</p>
  
  <pre><code>192.168.1.15 - - [12/Mar/2018:11:26:23 -0300] "GET /SafeHome/index.php HTTP/1.0" 200 8 "-" "-"
  </code></pre>
  
  <p>I'm using:</p>
  
  <pre><code>Arduino Uno;
  Ethernet Modulo ENC28J60;
  Library: &lt;EtherCard.h&gt;;
  Class: ether.httpPost;
  </code></pre>
  
  <p>What is wrong with my httpPost request?</p>
  
  <p>Why log request had this stranger format " "POST \xa9\x020\x91\xa7\x020\x93\xa9\x02..."?</p>
  
  <p>Following full code:</p>
  
  <pre><code>#include &lt;EtherCard.h&gt;
  
  #define REQUEST_RATE 5000 // milliseconds
  
  // ethernet interface mac address
  static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x33 };
  static byte myip[] = { 192,168,1,15 };
  static byte gwip[] = { 192,168,1,1 };
  static byte netmask[] = { 255,255,255,255 };//
  static byte dnsip[] = { 8,8,8,8 };
  static byte hisip[] = { 192,168,1,1 };//
  
  const char website[] PROGMEM = "192.168.1.1";
  
  
  byte Ethernet::buffer[300];
  static long timer;
  
  
  
  void setup () {
  
  Serial.begin(9600);
  Serial.println("\n[getStaticIP]");
  
  if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0) 
  Serial.println( "Failed to access Ethernet controller");
  
  ether.staticSetup(myip, gwip);
  
  
  
  if(ether.dnsLookup (website, false)){
  Serial.println( "dnsLookup ok");
  }else{
  Serial.println( "dnsLookup faild");
   ether.parseIp(ether.hisip, "192.168.1.1"); //IP do servidor manual
  }
  
  
  while (ether.clientWaitingGw())
  ether.packetLoop(ether.packetReceive());
  Serial.println("Gateway found");
  
  ether.printIp("My IP: ", ether.myip);
  ether.printIp("Netmask: ", ether.netmask);
  ether.printIp("GW IP: ", ether.gwip);
  ether.printIp("DNS IP: ", ether.dnsip);
  ether.printIp("SRV: ", ether.hisip);
  
  timer = - REQUEST_RATE; // start timing out right away
  }
  
  void loop () {
  ether.packetLoop(ether.packetReceive());
  
  if (millis() &gt; timer + REQUEST_RATE) {
  timer = millis();
  Serial.println("\n&gt;&gt;&gt; REQ");
  ether.hisport = 90;//to access  local host
  
  char *PATH="/SafeHome/addevent";
  char *contentType = "Content-Type: application/json";
  String postDataStr =  "{\"INSTALACAO_ID\": \"1\", \"TPEVENTO_ID\": \"1\",\"ZONA_ID\": \"1\"}";
  char *postDataChar = postDataStr.c_str();
  ether.httpPost(PATH, website, contentType, postDataChar, my_result_cb);
  
  }
  }
  
  // called when the client request is complete
  static void my_result_cb (byte status, word off, word len) {
  Serial.print("&lt;&lt;&lt; reply ");
  Serial.print(millis() - timer);
  Serial.println(" ms");
  Serial.println((const char*) Ethernet::buffer + off);
  }
  </code></pre>
  
  <ul>
  <li>Note: all services in serve side works fine, a can use POST, GET by PostMan.</li>
  </ul>
  
  <p>Arduino Code of GET Request:</p>
  
  <pre><code>void loop () {
  ether.packetLoop(ether.packetReceive());
  if (millis() &gt; timer + REQUEST_RATE) {
  timer = millis();
  Serial.println("\n&gt;&gt;&gt; REQ");
  ether.hisport = 90;//to access  local host
  ether.browseUrl(PSTR("/SafeHome/index.php"),"",website, my_result_cb);
  }
  }
  </code></pre>
  
  <p>This server Log printed for GET request:</p>
  
  <pre><code>192.168.1.15 - - [12/Mar/2018:11:20:55 -0300] "GET /SafeHome/index.php HTTP/1.0" 200 8 "-" "-"
  </code></pre>