| 29 | private final OkHttpClient client = new OkHttpClient(); |
| 30 | |
| 31 | public void run() throws Exception { |
| 32 | String postBody = "" |
| 33 | + "Releases\n" |
| 34 | + "--------\n" |
| 35 | + "\n" |
| 36 | + " * _1.0_ May 6, 2013\n" |
| 37 | + " * _1.1_ June 15, 2013\n" |
| 38 | + " * _1.2_ August 11, 2013\n"; |
| 39 | |
| 40 | Request request = new Request.Builder() |
| 41 | .url("https://api.github.com/markdown/raw") |
| 42 | .post(RequestBody.create(postBody, MEDIA_TYPE_MARKDOWN)) |
| 43 | .build(); |
| 44 | |
| 45 | try (Response response = client.newCall(request).execute()) { |
| 46 | if (!response.isSuccessful()) throw new IOException("Unexpected code " + response); |
| 47 | |
| 48 | System.out.println(response.body().string()); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | public static void main(String... args) throws Exception { |
| 53 | new PostString().run(); |