use of retrofit2.http.POST in project autorest.java by Azure.
the class LROsImpl method postAsyncNoRetrySucceededWithServiceResponseAsync.
/**
* Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponseWithHeaders<Product, LROsPostAsyncNoRetrySucceededHeaders>> postAsyncNoRetrySucceededWithServiceResponseAsync() {
final Product product = null;
Observable<Response<ResponseBody>> observable = service.postAsyncNoRetrySucceeded(product, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultWithHeadersAsync(observable, new TypeToken<Product>() {
}.getType(), LROsPostAsyncNoRetrySucceededHeaders.class);
}
use of retrofit2.http.POST in project autorest.java by Azure.
the class LROsImpl method postAsyncRetrycanceledWithServiceResponseAsync.
/**
* Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the observable for the request
*/
public Observable<ServiceResponseWithHeaders<Void, LROsPostAsyncRetrycanceledHeaders>> postAsyncRetrycanceledWithServiceResponseAsync() {
final Product product = null;
Observable<Response<ResponseBody>> observable = service.postAsyncRetrycanceled(product, this.client.acceptLanguage(), this.client.userAgent());
return client.getAzureClient().getPostOrDeleteResultWithHeadersAsync(observable, new TypeToken<Void>() {
}.getType(), LROsPostAsyncRetrycanceledHeaders.class);
}
use of retrofit2.http.POST in project autorest.java by Azure.
the class ParameterGroupingsImpl method postOptionalWithServiceResponseAsync.
/**
* Post a bunch of optional parameters grouped.
*
* @throws IllegalArgumentException thrown if parameters fail the validation
* @return the {@link ServiceResponse} object if successful.
*/
public Observable<ServiceResponse<Void>> postOptionalWithServiceResponseAsync() {
final ParameterGroupingPostOptionalParameters parameterGroupingPostOptionalParameters = null;
String customHeader = null;
Integer query = null;
return service.postOptional(this.client.acceptLanguage(), customHeader, query, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Void>>>() {
@Override
public Observable<ServiceResponse<Void>> call(Response<ResponseBody> response) {
try {
ServiceResponse<Void> clientResponse = postOptionalDelegate(response);
return Observable.just(clientResponse);
} catch (Throwable t) {
return Observable.error(t);
}
}
});
}
use of retrofit2.http.POST in project EssayJoke by qiyei2015.
the class RetrofitEngine method getMethodName.
/**
* 找到method
* @param task
* @return
*/
private String getMethodName(HttpTask task) {
String methodName = null;
// 这个循环找到method
for (Method method : task.getRequest().getApiClazz().getDeclaredMethods()) {
String value = null;
switch(task.getRequest().getMethod()) {
case HTTP.GET:
GET getAnnotation = method.getAnnotation(GET.class);
if (getAnnotation != null) {
value = getAnnotation.value();
}
break;
case HTTP.POST:
POST postAnnotation = method.getAnnotation(POST.class);
if (postAnnotation != null) {
value = postAnnotation.value();
}
break;
case HTTP.DOWNLOAD:
if (method.getAnnotation(Streaming.class) != null) {
GET downloadAnnotation = method.getAnnotation(GET.class);
if (downloadAnnotation != null) {
value = downloadAnnotation.value();
}
}
break;
case HTTP.UPLOAD:
if (method.getAnnotation(Multipart.class) != null) {
POST uploadAnnotation = method.getAnnotation(POST.class);
if (uploadAnnotation != null) {
value = uploadAnnotation.value();
}
}
break;
default:
break;
}
if (value != null && task.getRequest().getPathUrl().equals(value)) {
methodName = method.getName();
LogManager.v(HTTP.TAG, "method :" + methodName);
}
}
return methodName;
}
use of retrofit2.http.POST in project retrofit by square.
the class RequestBuilderTest method simpleMultipart.
@Test
public void simpleMultipart() throws IOException {
class Example {
//
@Multipart
//
@POST("/foo/bar/")
Call<ResponseBody> method(@Part("ping") String ping, @Part("kit") RequestBody kit) {
return null;
}
}
Request request = buildRequest(Example.class, "pong", RequestBody.create(MediaType.parse("text/plain"), "kat"));
assertThat(request.method()).isEqualTo("POST");
assertThat(request.headers().size()).isZero();
assertThat(request.url().toString()).isEqualTo("http://example.com/foo/bar/");
RequestBody body = request.body();
Buffer buffer = new Buffer();
body.writeTo(buffer);
String bodyString = buffer.readUtf8();
assertThat(bodyString).contains("Content-Disposition: form-data;").contains("name=\"ping\"\r\n").contains("\r\npong\r\n--");
assertThat(bodyString).contains("Content-Disposition: form-data;").contains("name=\"kit\"").contains("\r\nkat\r\n--");
}
Aggregations