Thanks for taking the time to post this source. It really helped me get started. On my server (ASP.NET MVC 4), I needed to replace this line:
client.println("Content-Type: application/x-www-form-urlencoded;");
with the following:
client.println("Content-Type: application/x-www-form-urlencoded; charset=UTF-8");
in order to get it to work without an error 500. Posting this just in case others run into the same issue.