當前位置: 首頁>>代碼示例>>Java>>正文


Java POST類代碼示例

本文整理匯總了Java中retrofit2.http.POST的典型用法代碼示例。如果您正苦於以下問題:Java POST類的具體用法?Java POST怎麽用?Java POST使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


POST類屬於retrofit2.http包,在下文中一共展示了POST類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: multipartPartMapSupportsSubclasses

import retrofit2.http.POST; //導入依賴的package包/類
@Test public void multipartPartMapSupportsSubclasses() throws IOException {
  class Foo extends HashMap<String, String> {
  }

  class Example {
    @Multipart //
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@PartMap Foo parts) {
      return null;
    }
  }

  Foo foo = new Foo();
  foo.put("hello", "world");

  Request request = buildRequest(Example.class, foo);
  Buffer buffer = new Buffer();
  request.body().writeTo(buffer);
  assertThat(buffer.readUtf8())
      .contains("name=\"hello\"")
      .contains("\r\n\r\nworld\r\n--");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:RequestBuilderTest.java

示例2: fieldMapRejectsNullKeys

import retrofit2.http.POST; //導入依賴的package包/類
@Test public void fieldMapRejectsNullKeys() {
  class Example {
    @FormUrlEncoded //
    @POST("/") //
    Call<ResponseBody> method(@FieldMap Map<String, Object> a) {
      return null;
    }
  }

  Map<String, Object> fieldMap = new LinkedHashMap<>();
  fieldMap.put("kit", "kat");
  fieldMap.put(null, "pong");

  try {
    buildRequest(Example.class, fieldMap);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Field map contained null key.");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:21,代碼來源:RequestBuilderTest.java

示例3: directLogin

import retrofit2.http.POST; //導入依賴的package包/類
@FormUrlEncoded
@POST("token")
Single<LoginResponse> directLogin(@Field("grant_type") String grantType,
                                  @Field("client_id") int clientId,
                                  @Field("client_secret") String clientSecret,
                                  @Field("username") String username,
                                  @Field("password") String password,
                                  @Field("v") String v,
                                  @Field("2fa_supported") int twoFaSupported,
                                  @Field("scope") String scope,
                                  @Field("code") String smscode,
                                  @Field("captcha_sid") String captchaSid,
                                  @Field("captcha_key") String captchaKey,
                                  @Field("force_sms") Integer forceSms);
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:15,代碼來源:IAuthService.java

示例4: search

import retrofit2.http.POST; //導入依賴的package包/類
@FormUrlEncoded
@POST("users.search")
Single<BaseResponse<Items<VKApiUser>>> search(@Field("q") String query,
                                              @Field("sort") Integer sort,
                                              @Field("offset") Integer offset,
                                              @Field("count") Integer count,
                                              @Field("fields") String fields,
                                              @Field("city") Integer city,
                                              @Field("country") Integer country,
                                              @Field("hometown") String hometown,
                                              @Field("university_country") Integer universityCountry,
                                              @Field("university") Integer university,
                                              @Field("university_year") Integer universityYear,
                                              @Field("university_faculty") Integer universityFaculty,
                                              @Field("university_chair") Integer universityChair,
                                              @Field("sex") Integer sex,
                                              @Field("status") Integer status,
                                              @Field("age_from") Integer ageFrom,
                                              @Field("age_to") Integer ageTo,
                                              @Field("birth_day") Integer birthDay,
                                              @Field("birth_month") Integer birthMonth,
                                              @Field("birth_year") Integer birthYear,
                                              @Field("online") Integer online,
                                              @Field("has_photo") Integer hasPhoto,
                                              @Field("school_country") Integer schoolCountry,
                                              @Field("school_city") Integer schoolCity,
                                              @Field("school_class") Integer schoolClass,
                                              @Field("school") Integer school,
                                              @Field("school_year") Integer schoolYear,
                                              @Field("religion") String religion,
                                              @Field("interests") String interests,
                                              @Field("company") String company,
                                              @Field("position") String position,
                                              @Field("group_id") Integer groupId,
                                              @Field("from_list") String fromList);
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:36,代碼來源:IUsersService.java

示例5: bodyRequired

import retrofit2.http.POST; //導入依賴的package包/類
@Test public void bodyRequired() {
  class Example {
    @POST("/foo/bar/") //
    Call<ResponseBody> method(@Body RequestBody body) {
      return null;
    }
  }
  try {
    buildRequest(Example.class, new Object[] { null });
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e.getMessage()).isEqualTo("Body parameter value must not be null.");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:RequestBuilderTest.java

示例6: downloadFile

import retrofit2.http.POST; //導入依賴的package包/類
@Streaming
@POST
Call<ResponseBody> downloadFile(@Url String fileUrl);
 
開發者ID:yzzslow0,項目名稱:Ec2m,代碼行數:4,代碼來源:RetrofitService.java

示例7: postRaw

import retrofit2.http.POST; //導入依賴的package包/類
@POST
Call<String> postRaw(@Url String url, @Body RequestBody body);
 
開發者ID:wang2016215,項目名稱:Bing,代碼行數:3,代碼來源:RestService.java

示例8: implicitFormEncodingByFieldForbidden

import retrofit2.http.POST; //導入依賴的package包/類
@Test public void implicitFormEncodingByFieldForbidden() {
  class Example {
    @POST("/") //
    Call<ResponseBody> method(@Field("a") int a) {
      return null;
    }
  }
  try {
    buildRequest(Example.class);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage(
        "@Field parameters can only be used with form encoding. (parameter #1)\n    for method Example.method");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RequestBuilderTest.java

示例9: alipayCheck

import retrofit2.http.POST; //導入依賴的package包/類
/**
 * 充值同步回調
 */
@Headers({HEADER_API_VERSION})
@FormUrlEncoded
@POST("payment/verifyResult")
Observable<BaseJson<JsonObject>> alipayCheck(@Field("_input_charset") String _input_charset, @Field("body") String body,
                                             @Field("currency") String currency, @Field("forex_biz") String forex_biz, @Field("notify_id") String notify_id, @Field("notify_time")
                                                     String notify_time, @Field("notify_type") String notify_type, @Field("notify_url") String notify_url, @Field("out_trade_no") String out_trade_no,
                                             @Field("partner") String partner, @Field("payment_type") String payment_type, @Field("return_url") String return_url, @Field("rmb_fee") String rmb_fee,
                                             @Field("seller_id") String seller_id, @Field("service") String service, @Field("sign") String sign, @Field("sign_type") String sign_type, @Field("subject")
                                                     String subject, @Field("success") String success, @Field("trade_no") String trade_no, @Field("trade_status") String trade_status);
 
開發者ID:Zyj163,項目名稱:yyox,代碼行數:13,代碼來源:UserService.java

示例10: formEncodedFieldOptional

import retrofit2.http.POST; //導入依賴的package包/類
@Test public void formEncodedFieldOptional() {
  class Example {
    @FormUrlEncoded //
    @POST("/foo") //
    Call<ResponseBody> method(@Field("foo") String foo, @Field("ping") String ping,
        @Field("kit") String kit) {
      return null;
    }
  }
  Request request = buildRequest(Example.class, "bar", null, "kat");
  assertBody(request.body(), "foo=bar&kit=kat");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:RequestBuilderTest.java

示例11: formEncodingFailsWithNoParts

import retrofit2.http.POST; //導入依賴的package包/類
@Test public void formEncodingFailsWithNoParts() {
  class Example {
    @FormUrlEncoded //
    @POST("/") //
    Call<ResponseBody> method() {
      return null;
    }
  }
  try {
    buildRequest(Example.class);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessage("Form-encoded method must contain at least one @Field.\n    for method Example.method");
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:RequestBuilderTest.java

示例12: setOnlineState

import retrofit2.http.POST; //導入依賴的package包/類
/**
 * 附近 模塊 api
 */

//附近的人 改變在線狀態
@Multipart
@POST("api.php?m=member&a=userStatus")
Observable<HttpResult<String>> setOnlineState(@Part("userid") String userid,
                                              @Part("type") String type);
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:10,代碼來源:ApiService.java

示例13: wanted

import retrofit2.http.POST; //導入依賴的package包/類
@FormUrlEncoded
@POST("wanted") Observable<ResponseModel_no_list> wanted(@Field("productName") String productName
        , @Field("price") String price
        , @Field("num") String num
        , @Field("userAddress.addressId") String addressId
        , @Field("deliveryTime") int deliveryTime
        , @Field("pack") int pack
        , @Field("deliveryArea") String deliveryArea
        , @Field("requirements") String requirements
        , @Field("picture") String picture
        , @Field("total") Double total
        , @Field("createType") String createType
);
 
開發者ID:linsir6,項目名稱:TripBuyer,代碼行數:14,代碼來源:Api.java

示例14: exchangeAward

import retrofit2.http.POST; //導入依賴的package包/類
@POST("/awards/{award_auth_token}/exchange")
Call<RewardContainer> exchangeAward(@Header("Authorization") String authToken,
        @Path("award_auth_token") String authTokenAward);
 
開發者ID:ArnauBlanch,項目名稱:civify-app,代碼行數:4,代碼來源:AwardService.java

示例15: createTask

import retrofit2.http.POST; //導入依賴的package包/類
@POST("/saveInfo")
Call<User> createTask(@Body User task);
 
開發者ID:attiqrehman1991,項目名稱:AndroidRepositoryWithOfflineMode,代碼行數:3,代碼來源:RetrofitLoginServices.java


注:本文中的retrofit2.http.POST類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。