Retrofit2 使用总结

Retrofit2官网

POST使用

参数少用@Field。

    @PUT("cloud-rbac/user/password")
    @Headers({"Content-Type: application/json", "Content-SHA-256: true"})
    Call<HttpBaseResult<String>> changePassword(@Field("oldPassword") String oldPassword, @Field("password") String password);

参数多用@Body,传递一个实体类。

    @PUT("cloud-rbac/user/password")
    @Headers({"Content-Type: application/json", "Content-SHA-256: true"})
	Call<HttpBaseResult<String>> changePassword(@Body ChangePasswordRequestBean data);

参数多用@PartMap传递RequestBody。

	@Multipart
    @POST("ezview/vehicle/gather")
    Call<HttpBaseResult<VehicleResponse>> uploadInfo(@PartMap Map<String, RequestBody> files);

猜你喜欢

转载自blog.csdn.net/zhijiandedaima/article/details/88058115