Java Code Examples for retrofit2.http.POST

The following are top voted examples for showing how to use retrofit2.http.POST. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GitHub   File: RequestBuilderTest.java   View source code 6 votes vote down vote up
@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--");
}
 
Example 2
Project: GitHub   File: RequestBuilderTest.java   View source code 6 votes vote down vote up
@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.");
  }
}
 
Example 3
Project: Phoenix-for-VK   File: IAuthService.java   View source code 5 votes vote down vote up
@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);
 
Example 4
Project: Phoenix-for-VK   File: IUsersService.java   View source code 5 votes vote down vote up
@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);
 
Example 5
Project: GitHub   File: RequestBuilderTest.java   View source code 5 votes vote down vote up
@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.");
  }
}
 
Example 6
Project: Ec2m   File: RetrofitService.java   View source code 5 votes vote down vote up
@Streaming
@POST
Call<ResponseBody> downloadFile(@Url String fileUrl);
 
Example 7
Project: Bing   File: RestService.java   View source code 5 votes vote down vote up
@POST
Call<String> postRaw(@Url String url, @Body RequestBody body);
 
Example 8
Project: GitHub   File: RequestBuilderTest.java   View source code 5 votes vote down vote up
@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");
  }
}
 
Example 9
Project: yyox   File: UserService.java   View source code 5 votes vote down vote up
/**
 * 充值同步回调
 */
@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);
 
Example 10
Project: GitHub   File: RequestBuilderTest.java   View source code 5 votes vote down vote up
@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");
}
 
Example 11
Project: GitHub   File: RequestBuilderTest.java   View source code 5 votes vote down vote up
@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");
  }
}
 
Example 12
Project: Tribe   File: ApiService.java   View source code 5 votes vote down vote up
/**
 * 附近 模块 api
 */

//附近的人 改变在线状态
@Multipart
@POST("api.php?m=member&a=userStatus")
Observable<HttpResult<String>> setOnlineState(@Part("userid") String userid,
                                              @Part("type") String type);
 
Example 13
Project: TripBuyer   File: Api.java   View source code 5 votes vote down vote up
@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
);
 
Example 14
Project: civify-app   File: AwardService.java   View source code 4 votes vote down vote up
@POST("/awards/{award_auth_token}/exchange")
Call<RewardContainer> exchangeAward(@Header("Authorization") String authToken,
        @Path("award_auth_token") String authTokenAward);
 
Example 15
Project: AndroidRepositoryWithOfflineMode   File: RetrofitLoginServices.java   View source code 4 votes vote down vote up
@POST("/saveInfo")
Call<User> createTask(@Body User task);
 
Example 16
Project: ImageClassify   File: CheckinService.java   View source code 4 votes vote down vote up
@FormUrlEncoded
@POST("user/checkin")
Call<HttpResult<String>> checkin(@Field(ApiConstant.OAUTH_TOKEN) String oauth_token);
 
Example 17
Project: GongXianSheng   File: RunwiseService.java   View source code 4 votes vote down vote up
@POST("/api/inventory/state")
Observable<EmptyResponse> cancleMakeInventory(@Body CancelMakeInventoryRequest cancelMakeInventoryRequest);
 
Example 18
Project: azure-libraries-for-java   File: IotHubResourcesInner.java   View source code 4 votes vote down vote up
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.devices.IotHubResources checkNameAvailability" })
@POST("subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability")
Observable<Response<ResponseBody>> checkNameAvailability(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body OperationInputs operationInputs, @Header("User-Agent") String userAgent);
 
Example 19
Project: azure-libraries-for-java   File: DomainsInner.java   View source code 4 votes vote down vote up
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.appservice.Domains checkAvailability" })
@POST("subscriptions/{subscriptionId}/providers/Microsoft.DomainRegistration/checkDomainAvailability")
Observable<Response<ResponseBody>> checkAvailability(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body NameIdentifierInner identifier, @Header("User-Agent") String userAgent);
 
Example 20
Project: xifan   File: ApiFactory.java   View source code 4 votes vote down vote up
@POST(Constants.FanFou.PHOTOS_UPLOAD_URL)
@Multipart
Observable<HttpResponseData<StatusRes>> uploadPhoto(@PartMap Map<String, RequestBody> bodyMap);
 
Example 21
Project: CXJPadProject   File: BService.java   View source code 4 votes vote down vote up
@POST("/pad/order/queryStoreAdapterSku")
Call<RMResponse<QueryStoreAdapterSkuRepModel>> queryStoreAdapterSku(@Body QueryStoreAdapterSkuReqModel model);
 
Example 22
Project: JPascalCoin   File: PascalCoinService.java   View source code 4 votes vote down vote up
@Headers({"Content-Type: application/json","User-Agent: JPascalCoin"})
@POST("/")
   Call<OpResult<Integer>> getBlockCount(@Body Map<String, Object> body);
 
Example 23
Project: filestack-java   File: CloudService.java   View source code 4 votes vote down vote up
@POST("folder/list")
Call<JsonObject> list(@Body JsonObject body);
 
Example 24
Project: InstantAppStarter   File: AppApiHelper.java   View source code 4 votes vote down vote up
@POST("login")
Observable<UserResponse> getResults();
 
Example 25
Project: azure-libraries-for-java   File: CdnManagementClientImpl.java   View source code 4 votes vote down vote up
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cdn.CdnManagementClient listResourceUsage" })
@POST("subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage")
Observable<Response<ResponseBody>> listResourceUsage(@Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
 
Example 26
Project: JPascalCoin   File: PascalCoinService.java   View source code 4 votes vote down vote up
@Headers({"Content-Type: application/json","User-Agent: JPascalCoin"})
@POST("/")
   Call<OpResult<List<Operation>>> getPendings(@Body Map<String, Object> body);
 
Example 27
Project: search-dialog   File: UsersService.java   View source code 4 votes vote down vote up
@POST("api/users")
Call<ArrayList<UserModel>> getFakeUsersBasedOnASearchTag(@Body String tag);
 
Example 28
Project: retrofit-converter-msgpack   File: MessagePackConverterFactoryTest.java   View source code 4 votes vote down vote up
@POST("/")
Call<Pojo> postPojo(@Body Pojo pojo);
 
Example 29
Project: telegram-bot-api   File: BotApi.java   View source code 4 votes vote down vote up
@FormUrlEncoded
@POST("/bot{apiToken}/kickChatMember")
Call<ApiResponse<Boolean>> kickChatMember(@Path("apiToken") String apiToken, @Field("chat_id") long chatId, @Field("user_id") long userId);
 
Example 30
Project: JPascalCoin   File: PascalCoinService.java   View source code 4 votes vote down vote up
@Headers({"Content-Type: application/json","User-Agent: JPascalCoin"})
@POST("/")
   Call<OpResult<List<Operation>>> changeKeys(@Body Map<String, Object> body);
 
Example 31
Project: schulcloud-mobile-android   File: RestService.java   View source code 4 votes vote down vote up
@POST("homework")
Observable<AddHomeworkResponse> addHomework(@Header("Authorization") String accessToken, @Body AddHomeworkRequest addHomeworkRequest);
 
Example 32
Project: FederatedAndroidTrainer   File: ServerService.java   View source code 4 votes vote down vote up
@POST("/service/federatedservice/gradient")
Observable<Boolean> uploadGradient(@Body RequestBody gradient);
 
Example 33
Project: CXJPadProject   File: BService.java   View source code 4 votes vote down vote up
@POST("pad/customermgmt/updateMdmMobile")
Call<RMResponse<BModel>> updateMdmMobile(@Body Map<String, String> params);
 
Example 34
Project: azure-libraries-for-java   File: PacketCapturesInner.java   View source code 4 votes vote down vote up
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.network.PacketCaptures stop" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkWatchers/{networkWatcherName}/packetCaptures/{packetCaptureName}/stop")
Observable<Response<ResponseBody>> stop(@Path("resourceGroupName") String resourceGroupName, @Path("networkWatcherName") String networkWatcherName, @Path("packetCaptureName") String packetCaptureName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
 
Example 35
Project: azure-libraries-for-java   File: NamespacesInner.java   View source code 4 votes vote down vote up
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.servicebus.Namespaces regenerateKeys" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ServiceBus/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys")
Observable<Response<ResponseBody>> regenerateKeys(@Path("resourceGroupName") String resourceGroupName, @Path("namespaceName") String namespaceName, @Path("authorizationRuleName") String authorizationRuleName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Body RegenerateKeysParameters parameters, @Header("User-Agent") String userAgent);
 
Example 36
Project: filestack-java   File: CloudService.java   View source code 4 votes vote down vote up
@POST("prefetch")
Call<AppInfo> prefetch(@Body JsonObject body);
 
Example 37
Project: Rey-MusicPlayer   File: LastFmInterface.java   View source code 4 votes vote down vote up
@POST
Call<ResponseBody> getJustin(@Url String url);
 
Example 38
Project: azure-libraries-for-java   File: VirtualNetworkGatewaysInner.java   View source code 4 votes vote down vote up
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.network.VirtualNetworkGateways beginGetLearnedRoutes" })
@POST("subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes")
Observable<Response<ResponseBody>> beginGetLearnedRoutes(@Path("resourceGroupName") String resourceGroupName, @Path("virtualNetworkGatewayName") String virtualNetworkGatewayName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
 
Example 39
Project: Daejeon-People   File: APIinterface.java   View source code 4 votes vote down vote up
@FormUrlEncoded
@POST("/signup/email/demand")
Call<Void> doSignUpDemandE(@Field("email") String email);
 
Example 40
Project: africastalking-android   File: PaymentServiceInterface.java   View source code 4 votes vote down vote up
@POST("card/checkout/charge")
Call<CheckoutResponse> cardCheckoutCharge(@Body HashMap<String, Object> body);