@Test public void formEncodingFailsOnNonBodyMethod() { class Example { @FormUrlEncoded // @GET("/") // Call<ResponseBody> method() { return null; } } try { buildRequest(Example.class); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage( "FormUrlEncoded can only be specified on HTTP methods with request body (e.g., @POST).\n for method Example.method"); } }
@Test public void onlyOneEncodingIsAllowedFormEncodingFirst() { class Example { @FormUrlEncoded // @Multipart // @POST("/") // Call<ResponseBody> method() { return null; } } try { buildRequest(Example.class); fail(); } catch (IllegalArgumentException e) { assertThat(e).hasMessage( "Only one encoding annotation is allowed.\n for method Example.method"); } }
@FormUrlEncoded @POST("wall.post") Single<BaseResponse<PostCreateResponse>> post(@Field("owner_id") Integer ownerId, @Field("friends_only") Integer friendsOnly, @Field("from_group") Integer fromGroup, @Field("message") String message, @Field("attachments") String attachments, @Field("services") String services, @Field("signed") Integer signed, @Field("publish_date") Long publishDate, @Field("lat") Double latitude, @Field("long") Double longitude, @Field("place_id") Integer placeId, @Field("post_id") Integer postId, @Field("guid") Integer guid, @Field("mark_as_ads") Integer markAsAds, @Field("ads_promoted_stealth") Integer adsPromotedStealth);
@Test public void simpleFormEncoded() { class Example { @FormUrlEncoded // @POST("/foo") // Call<ResponseBody> method(@Field("foo") String foo, @Field("ping") String ping) { return null; } } Request request = buildRequest(Example.class, "bar", "pong"); assertBody(request.body(), "foo=bar&ping=pong"); }
@POST("order/new") @FormUrlEncoded Flowable<ResponseDto> add( @Field("deviceId") String deviceId, @Field("price") float price, @Field("adOwner") String adOwner, @Field("deviceOwner") String deviceOwner, @Field("token") String token );
@FormUrlEncoded @POST("groups.editManager") Single<BaseResponse<Integer>> editManager(@Field("group_id") int groupId, @Field("user_id") int userId, @Field("role") String role, @Field("is_contact") Integer isContact, @Field("contact_position") String contactPosition, @Field("contact_phone") String contactPhone, @Field("contact_email") String contactEmail);
@Test public void formEncodedWithEncodedNameFieldParam() { class Example { @FormUrlEncoded // @POST("/foo") // Call<ResponseBody> method(@Field(value = "na%20me", encoded = true) String foo) { return null; } } Request request = buildRequest(Example.class, "ba%20r"); assertBody(request.body(), "na%20me=ba%20r"); }
@POST @FormUrlEncoded Observable<Response<AccessToken>> getAccessToken(@Url String url, @Field("client_id") String clientId, @Field("client_secret") String clientSecret, @Field("code") String code, @Field("redirect_uri") String redirect_uri);
@FormUrlEncoded @POST("upload/music") Observable<UploadResponse> uploadMusic(@Field("name") String name, @Field("author") String author, @Field("authorID") Integer authorID, @Field("authorAvatarName") String authorAvatarName, @Field("date") String date, @Field("musicName") String musicName, @Field("imgName") String imgName, @Field("musicInfo") String musicInfo);
@FormUrlEncoded @POST("audio.search") Single<BaseResponse<Items<VKApiAudio>>> search(@Field("q") String query, @Field("auto_complete") Integer autoComplete, @Field("lyrics") Integer lyrics, @Field("performer_only") Integer performerOnly, @Field("sort") Integer sort, @Field("search_own") Integer searchOwn, @Field("offset") Integer offset, @Field("count") Integer count);
@Headers({ "Authorization:Basic ZnJvbnRlbmQ6", "Content-Type:application/x-www-form-urlencoded" }) @FormUrlEncoded @POST("login/oauth") Call<AccessToken> getAccessToken(@Field("username") String username, @Field("password") String password, @Field("grant_type") String grant_type);
@POST("sys/comments/new") @FormUrlEncoded Flowable<ResponseDto> comment( @Field("account") String account, @Field("content") String content, @Field("token") String token );
@POST("ajaxik.php") @FormUrlEncoded Observable<TvShowsResponse> getTvShows(@Field("act") String act, @Field("type") String type, @Field("o") int offset, @Field("s") int searchType, @Field("t") int t);
@POST("order/update") @FormUrlEncoded Flowable<ResponseDto> updateAd( @Field("id") String id, @Field("adId") String adId, @Field("token") String token );
/** * { "status": 0, "msg": "success" } */ @FormUrlEncoded @POST("reqfilter/{iconpack}/{user}") Call<ResResBean> filterPkg(@Path("iconpack") String iconPack, @Path("user") String user, @Field("pkg") String pkgName, @Field("launcher") String launcherActivity);
@FormUrlEncoded @POST("api.php?m=activity&a=add") Observable<HttpResult<String>> releaseActivity(@Field("userid") String userId, @Field("country_id") String countryId, @Field("name") String name, @Field("address") String address, @Field("start_time") String startTime, @Field("end_time") String endTime, @Field("fee") String fee, @Field("num") String num, @Field("sponsor") String sponsor, @Field("desc") String content, @Field("index_pics") String coverImg, @Field("detail_pics") String detailPics);
@POST("groups.banUser") @FormUrlEncoded Single<BaseResponse<Integer>> banUser(@Field("group_id") int groupId, @Field("user_id") int userId, @Field("end_date") Long endDate, @Field("reason") Integer reason, @Field("comment") String comment, @Field("comment_visible") Integer commentVisible);
@FormUrlEncoded @POST("wall.getComments") Single<BaseResponse<DefaultCommentsResponse>> getComments(@Field("owner_id") Integer ownerId, @Field("post_id") int postId, @Field("need_likes") Integer needLikes, @Field("start_comment_id") Integer startCommentId, @Field("offset") Integer offset, @Field("count") Integer count, @Field("sort") String sort, @Field("extended") Integer extended, @Field("fields") String fields);
@FormUrlEncoded @POST("api.php?m=activity&a=activityList") Observable<HttpResult<List<CommentBean>>> getMyCommentList(@Field("userid") String userId);
@FormUrlEncoded @POST Call<ResponseBody> post(@Url String url, @FieldMap Map<String,String>map);
@FormUrlEncoded @POST("/logout") Call<Void> doLogOut();
@FormUrlEncoded @POST("weiPay/wantedPay") Observable<ResponseModel_no_list> weiXin_xuanShang(@Field("id") String orderId);
/** * 登录 */ @FormUrlEncoded @POST(BaseApi.Url.URL_REGISTER) Observable<JSONObject> login(@FieldMap Map<String, String> map);
@FormUrlEncoded @POST("/bot{apiToken}/exportChatInviteLink") Call<ApiResponse<String>> exportChatInviteLink(@Path("apiToken") String apiToken, @Field("chat_id") long chatId);
@FormUrlEncoded @POST("login") Call<LoginBean> login(@Field("username") String user, @Field("password") String pwd);
@FormUrlEncoded @POST("/bot{apiToken}/restrictChatMember") Call<ApiResponse<Boolean>> restrictChatMember(@Path("apiToken") String apiToken, @Field("chat_id") String chatId, @Field("user_id") long userId, @Field("until_date") Long untilDate, @Field("can_send_messages") Boolean canSendMessage, @Field("can_send_media_messages") Boolean canSendMediaMessage, @Field("can_send_other_messages") Boolean canSendOtherMessage, @Field("can_add_web_page_previews") Boolean canAddWebPagePreviews);
@FormUrlEncoded @POST("getArticleList") Observable<HttpResult<ArticleListResult>> getArticleList2( @Field("pageSize") int pageSize, @Field("page") int page);
@FormUrlEncoded @POST("passcodeNew/checkRandCodeAnsyn") Observable<CheckRandCodeResponse> checkRandCode(@Field(value = "randCode", encoded = true) String randCode, @Field("rand") String rand);
@FormUrlEncoded @POST("api.php?m=activity&a=clearList") Observable<HttpResult<String>> clearCommentList(@Field("userid") String userId);
@FormUrlEncoded @Headers(AUTHORIZATION_HEADER) @POST("/api/tresor/invited-user") retrofit2.Call<Void> sharedTresor(@Field("operationId") String operationId);
@FormUrlEncoded @POST("task/getfinishedtask") Call<HttpResult<List<Task>>> getFinishedTask(@Field(ApiConstant.OAUTH_TOKEN) String token, @Field(ApiConstant.START) String start, @Field(ApiConstant.PAGE_NUM) String pageNum);
@FormUrlEncoded @POST("fave.addUser") Single<BaseResponse<Integer>> addUser(@Field("user_id") int userId);
@FormUrlEncoded @POST("fave.addGroup") Single<BaseResponse<Integer>> addGroup(@Field("group_id") int groupId);
@POST("/auth/") @FormUrlEncoded Call<CsrfToken> perform(@Field("username") String username, @Field("password") String password);
@FormUrlEncoded @POST("allAddress") Observable<ResponseModel<List<AllAddress>>> allAddress(@Field("wid") int noMain);
@FormUrlEncoded @POST(Constants.LOGIN_ENDPOINT) Call<User> attemptLogin(@Field("user_email") String email, @Field("password") String password);
@FormUrlEncoded @POST("user/update_user_info.shtml") Observable<BaseJson<LoginInfo>> updateUserInfo(@FieldMap Map<String, String> body);
@FormUrlEncoded @POST("/api.php/Public/login_json") Call<User> login(@Field("phone") String phone,@Field("code") String code);
@FormUrlEncoded @POST("/api.php/Public/send_sms_json") Call<JsonObject> getCode(@Field("phone") String phone);