最近项目需要post上传json数据
1.在APIService处参数的格式需要标注为:RequestBody
//登录
@Headers("Content-Type: application/json")
@POST("api/Student/AddStudent")
Observable>addStudents(@Body RequestBody array);
2.在传递参数时需要将json转换为RequestBody
public static finalMediaTypeJSON= MediaType.parse("application/json; charset=utf-8");
RequestBody body = RequestBody.create(JSON,String);
网友评论