okhttp發送post請求

String url = "http://www.xxx.com/api/test";OkHttpClient httpClient = new OkHttpClient();MediaType mediaType = MediaType.parse("application/json;charset=UTF-8");String post = "{\"test\":123}";RequestBody requestBody = RequestBody.create(mediaType, post);Request request = new Request.Builder()        .post(requestBody)        .url(url)        .build();Response response = httpClient.newCall(request).execute();
相關文章
相關標籤/搜索