本文整理汇总了Java中retrofit2.http.FormUrlEncoded类的典型用法代码示例。如果您正苦于以下问题:Java FormUrlEncoded类的具体用法?Java FormUrlEncoded怎么用?Java FormUrlEncoded使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FormUrlEncoded类属于retrofit2.http包,在下文中一共展示了FormUrlEncoded类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: formEncodingFailsOnNonBodyMethod
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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");
}
}
示例2: onlyOneEncodingIsAllowedFormEncodingFirst
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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");
}
}
示例3: post
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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);
示例4: simpleFormEncoded
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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");
}
示例5: add
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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
);
示例6: editManager
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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);
示例7: formEncodedWithEncodedNameFieldParam
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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");
}
示例8: getAccessToken
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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);
示例9: uploadMusic
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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);
示例10: search
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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);
示例11: getAccessToken
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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);
示例12: comment
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@POST("sys/comments/new")
@FormUrlEncoded
Flowable<ResponseDto> comment(
@Field("account") String account,
@Field("content") String content,
@Field("token") String token
);
示例13: getTvShows
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@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);
示例14: updateAd
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
@POST("order/update")
@FormUrlEncoded
Flowable<ResponseDto> updateAd(
@Field("id") String id,
@Field("adId") String adId,
@Field("token") String token
);
示例15: filterPkg
import retrofit2.http.FormUrlEncoded; //导入依赖的package包/类
/**
* { "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);