Tag: okhttp3

发布JSON到NodeJS服务器显示成功时,它实际上是一个失败

这是我的android代码发布到我的nodejs服务器 registrationjson.setUsername(username.getText().toString()); registrationjson.setPassword(password.getText().toString()); Gson gson = new Gson(); String jsonfromForm = gson.toJson(registrationjson); client = new OkHttpClient(); RequestBody body = RequestBody.create(JSON, jsonfromForm); Request request = new Request.Builder() .url(uri) .post(body) .addHeader("content-type", "application/json; charset=utf-8") .build(); client.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { System.out.println("Failure!!"); } @Override public void onResponse(Call call, Response response) throws IOException { […]