那夜我还很年幼~
我不去想身后会不会袭来寒风冷雨 既然目标是地平线 留给世界的只能是背影
import okhttp3.OkHttpClient;
import okhttp3.FormBody;
import okhttp3.Request;
import okhttp3.RequestBody;




// HashMap with Params
HashMap<String, String> params = new HashMap<>();
params.put( "Param1", "A" );
params.put( "Param2", "B" );

// Initialize Builder (not RequestBody)
FormBody.Builder builder = new FormBody.Builder();

// Add Params to Builder
for ( Map.Entry<String, String> entry : params.entrySet() ) {
    builder.add( entry.getKey(), entry.getValue() );
}

// Create RequestBody
RequestBody formBody = builder.build();

// Create Request (same)
Request request = new Request.Builder()
        .url( "url" )
        .post( formBody )
        .build();

 

posted on 2016-04-08 18:27  那夜我还很年幼~  阅读(3311)  评论(0编辑  收藏  举报