0
我在發佈的數據與OkHttp3在Android上Challonge API的問題
...這是我的代碼JIST:404錯誤與POST和OkHttp3
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)
時,其立即404s。
爲Challonge API的文檔是在這裏: http://api.challonge.com/v1/documents/participants/create
哦,天哪......我是個白癡。已經連續20小時編程,我想我失去了一點。 –