retrofit.http.Headers Java Examples

The following examples show how to use retrofit.http.Headers. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PatrulatrulAPI.java    From patrol-android with GNU General Public License v3.0 6 votes vote down vote up
@Multipart
@Headers({"Content-Type: multipart/form-data",
        "Accept: application/json",
        "Accept-Encoding: gzip, deflate"})
@POST("/api/{userID}/violation/create")
VideoAnswer uploadImage(@Part("photo") TypedFile photo,
                        @EncodedPath("userID") String userID,
                        @Part("latitude") double latitude,
                        @Part("longitude") double longitude);
 
Example #2
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Headers("Accept: application/text")
@GET("/analytics/events/{dataType}/{program}"
        + ".html+css?displayProperty=NAME")
Response getEventReportTableData(@Path("program") String program,
        @Query("stage") String programStage,
        @Query("dimension") List<String> dimensions,
        @Query("outputType") String outputType,
        @Query("aggregationType") String aggregationType,
        @Query("value") String value,
        @Path("dataType") String dataType,
        @Query("filter") List<String> filter);
 
Example #3
Source File: BitlyRetrofitService.java    From android-auth-manager with Apache License 2.0 5 votes vote down vote up
@Headers({ACCEPT_JSON_HEADER})
@FormUrlEncoded
@POST("/oauth/access_token")
BitlyOAuthToken getToken(@Header("Authorization") String authorizationHeader,
                                 @Field("grant_type") String grantType,
                                 @Field("username") String username,
                                 @Field("password") String password);
 
Example #4
Source File: OAuthGitHubWebFlow.java    From githot with Apache License 2.0 5 votes vote down vote up
@Headers({
        "Accept: application/json"
})
@FormUrlEncoded
@POST("/login/oauth/access_token")
Observable<AccessTokenResponse> getOAuthToken(@Field("client_id") String client_id,
                                              @Field("client_secret") String client_secret, @Field("code") String code);
 
Example #5
Source File: ApiService.java    From githot with Apache License 2.0 5 votes vote down vote up
@Headers({
        "Content-Length: 0",
        "Accept: application/json"
})
@PUT("/user/starred/{user}/{repo}")
Observable<Object> starRepo(
        @Path("user") String user, @Path("repo") String repo,
        @Query(value = "access_token", encodeValue = true) String accessToken
);
 
Example #6
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GET("/documents?paging=false")
@Headers("Accept: application/json")
Map<String, List<DashboardItemContent>> getResources(@QueryMap Map<String, String> queryMap);
 
Example #7
Source File: GithubService.java    From TutosAndroidFrance with MIT License 4 votes vote down vote up
@Headers("Cache-Control: max-age=640000")
@GET("/users/{user}/repos")
List<Repo> listRepos(@Path("user") String user);
 
Example #8
Source File: DexcomShare.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/DoesContactExistByName")
@Headers({"Content-Length: 0"})
Call<ResponseBody> doesContactExist(@Query("sessionId") String sessionId,
                                    @Query("contactName") String contactName);
 
Example #9
Source File: DexcomShare.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/CreateContact")
@Headers({"Content-Length: 0"})
Call<String> createContact(@Query("sessionId") String sessionId,
                                 @Query("contactName") String contactName,
                                 @Query("emailAddress") String emailAddress);
 
Example #10
Source File: DexcomShare.java    From xDrip-Experimental with GNU General Public License v3.0 4 votes vote down vote up
@POST("Publisher/DeleteContact")
@Headers({"Content-Length: 0"})
Call<ResponseBody> deleteContact(@Query("sessionId") String sessionId,
                                 @Query("contactId") String contactId);
 
Example #11
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GET("/maps?paging=false")
@Headers("Accept: application/json")
Map<String, List<DashboardItemContent>> getMaps(@QueryMap Map<String, String> queryParams);
 
Example #12
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Headers("Accept: application/text")
@GET("/reportTables/{id}/data.html")
Response getReportTableData(@Path("id") String id);
 
Example #13
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@DELETE("/26/dashboards/{dashboardUid}/items/{itemUid}/content/{contentUid}")
@Headers("Content-Type: application/json")
Response deleteDashboardItemContent(@Path("dashboardUid") String dashboardUid,
                                    @Path("itemUid") String itemUid,
                                    @Path("contentUid") String contentUid);
 
Example #14
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GET("/charts?paging=false")
@Headers("Accept: application/json")
Map<String, List<DashboardItemContent>> getCharts(@QueryMap Map<String, String> queryParams);
 
Example #15
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GET("/interpretations/{uid}")
@Headers("Accept: application/json")
Interpretation getInterpretation(@Path("uid") String uId, @QueryMap Map<String, String> queryMap);
 
Example #16
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GET("/reportTables?paging=false")
@Headers("Accept: application/json")
Map<String, List<DashboardItemContent>> getReportTables(@QueryMap Map<String, String> queryParams);
 
Example #17
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Headers("Content-Type: text/plain")
@POST("/interpretations/map/{uid}")
Response postMapInterpretation(@Path("uid") String elementUid,
                               @Body TypedString interpretationText);
 
Example #18
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@GET("/me/")
@Headers("Accept: application/json")
UserAccount getCurrentUserAccount(@QueryMap Map<String, String> queryParams);
 
Example #19
Source File: DhisApi.java    From dhis2-android-dashboard with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Headers("Content-Type: text/plain")
@POST("/interpretations/reportTable/{uid}")
Response postReportTableInterpretation(@Path("uid") String elementUid,
                                       @Body TypedString interpretationText);
 
Example #20
Source File: MattermostService.java    From mattermost-android-classic with Apache License 2.0 4 votes vote down vote up
@Headers("X-Requested-With: XMLHttpRequest")
@PUT("/api/v4/users/sessions/device")
Promise<User> attachDeviceV4(@Body User user);
 
Example #21
Source File: MattermostService.java    From mattermost-android-classic with Apache License 2.0 4 votes vote down vote up
@Headers("X-Requested-With: XMLHttpRequest")
@POST("/api/v3/users/attach_device")
Promise<User> attachDeviceV3(@Body User user);
 
Example #22
Source File: ApiService.java    From materialup with Apache License 2.0 4 votes vote down vote up
@Headers("Accept: application/json")
@PATCH("/notifications/viewed")
Observable<ResponseBody> patchNotifications();
 
Example #23
Source File: ApiService.java    From materialup with Apache License 2.0 4 votes vote down vote up
@Headers("Accept: application/json")
@GET("/notifications/preview")
Observable<MuResponse> getNotifications();
 
Example #24
Source File: RestMethodInfo.java    From android-discourse with Apache License 2.0 4 votes vote down vote up
/**
 * Loads {@link #requestMethod} and {@link #requestType}.
 */
private void parseMethodAnnotations() {
    for (Annotation methodAnnotation : method.getAnnotations()) {
        Class<? extends Annotation> annotationType = methodAnnotation.annotationType();
        RestMethod methodInfo = null;

        // Look for a @RestMethod annotation on the parameter annotation indicating request method.
        for (Annotation innerAnnotation : annotationType.getAnnotations()) {
            if (RestMethod.class == innerAnnotation.annotationType()) {
                methodInfo = (RestMethod) innerAnnotation;
                break;
            }
        }

        if (methodInfo != null) {
            if (requestMethod != null) {
                throw new IllegalArgumentException("Method " + method.getName() + " contains multiple HTTP methods. Found: " + requestMethod + " and " + methodInfo.value());
            }
            String path;
            try {
                path = (String) annotationType.getMethod("value").invoke(methodAnnotation);
            } catch (Exception e) {
                throw new RuntimeException("Failed to extract path from " + annotationType.getSimpleName() + " annotation on " + method.getName() + ".", e);
            }
            parsePath(path);
            requestMethod = methodInfo.value();
            requestHasBody = methodInfo.hasBody();
        } else if (annotationType == Headers.class) {
            String[] headersToParse = ((Headers) methodAnnotation).value();
            if (headersToParse.length == 0) {
                throw new IllegalStateException("Headers annotation was empty.");
            }
            headers = parseHeaders(headersToParse);
        } else if (annotationType == Multipart.class) {
            if (requestType != RequestType.SIMPLE) {
                throw new IllegalStateException("Only one encoding annotation per method is allowed: " + method.getName());
            }
            requestType = RequestType.MULTIPART;
        } else if (annotationType == FormUrlEncoded.class) {
            if (requestType != RequestType.SIMPLE) {
                throw new IllegalStateException("Only one encoding annotation per method is allowed: " + method.getName());
            }
            requestType = RequestType.FORM_URL_ENCODED;
        }
    }

    if (requestMethod == null) {
        throw new IllegalStateException("Method " + method.getName() + " not annotated with request type (e.g., GET, POST).");
    }
    if (!requestHasBody) {
        if (requestType == RequestType.MULTIPART) {
            throw new IllegalStateException("Multipart can only be specific on HTTP methods with request body (e.g., POST). (" + method.getName() + ")");
        }
        if (requestType == RequestType.FORM_URL_ENCODED) {
            throw new IllegalStateException("Multipart can only be specific on HTTP methods with request body (e.g., POST). (" + method.getName() + ")");
        }
    }
}
 
Example #25
Source File: ApiService.java    From materialup with Apache License 2.0 4 votes vote down vote up
@Headers("Accept: application/json")
@POST("/posts/{pid}/comments")
Observable<Comment> postComment(@Path("pid") long pid, @Body RequestBody body);
 
Example #26
Source File: OWMService.java    From android-clean-architecture-mvp with Apache License 2.0 4 votes vote down vote up
@GET("/data/2.5/find?units=metric")
@Headers("Cache-Control: max-age=300, max-stale=900")
OWMCurrentWeatherList getCurrentWeatherByCityName(@Query("q") String query);
 
Example #27
Source File: ApiService.java    From materialup with Apache License 2.0 4 votes vote down vote up
@Headers("Accept: application/json")
@PUT("/users/{uid}/unfollow")
Observable<Follow> unfollow(@Path("uid") String uid);
 
Example #28
Source File: ApiService.java    From materialup with Apache License 2.0 4 votes vote down vote up
@Headers("Accept: application/json")
@PUT("/posts/{pid}/comments/{cid}/unlike")
Observable<Comment> unlikedComment(@Path("pid") long pid, @Path("cid") long cid);
 
Example #29
Source File: ApiService.java    From materialup with Apache License 2.0 4 votes vote down vote up
@Headers("Accept: application/json")
@PUT("/posts/{pid}/comments/{cid}/like")
Observable<Comment> likedComment(@Path("pid") long pid, @Path("cid") long cid);
 
Example #30
Source File: ApiService.java    From materialup with Apache License 2.0 4 votes vote down vote up
@Headers("Accept: application/json")
@GET("/notifications/preview")
Observable<MuResponse> checkLogin();