AndroidでOkHttp3を使用してChallonge APIにデータを投稿する際に問題が発生しています...これは私のコードの要旨です:
OkHttpClient client = new OkHttpClient();
HttpUrl.Builder urlBuilder = new HttpUrl.Builder();
urlBuilder = HttpUrl.parse("https://api.challonge.com/v1/tournaments/"+EVENT_ID+".json")
.newBuilder();
RequestBody postBody = new FormBody.Builder()
.add("_method", "post")
.add("api_key", API_KEY)
.add("participant[name]", name.getText().toString())
.add("participant[misc]", forum_id.getText().toString())
.build();
Request request = new Request.Builder()
.url(urlBuilder.build().toString())
.post(postBody)
.build();
Response response = client.newCall(request).execute();
何をしても、結果の応答は 404 ページです。
同じ URL に対して GET 応答を行うと、適切な応答が得られます。ただし、.post(postBody)リクエストに追加するとすぐに 404 になります。
Challonge API のドキュメントはこちら: http://api.challonge.com/v1/documents/participants/create