OkHttp 如何提交 POST 请求?

2021-04-01 10:26

阅读:643

标签:manager   parse   http   form   response   request   user   nfa   build   

2020-03-25

关键字:


 

 废话少说,上代码:

String travelIdJson = String.format(Locale.US, "{\"travelId\":[%d]}", track.getId());
RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), travelIdJson);
Request request = new Request.Builder()
        .url(ServerInfoManager.URL)
        .post(body)
        .addHeader("Authorization", DataManager.getUserManager().getToken())
        .build();

Call call = new OkHttpClient().newCall(request);
call.enqueue(new Callback() {

    @Override
    public void onFailure(Call call, IOException e) {
        
    }

    @Override
    public void onResponse(Call call, Response response) throws IOException {
        
    }

});

 


 

OkHttp 如何提交 POST 请求?

标签:manager   parse   http   form   response   request   user   nfa   build   

原文地址:https://www.cnblogs.com/chorm590/p/11612898.html


评论


亲,登录后才可以留言!