Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does Method getResources not annotated with request type (e.g., GET, POST) mean?

Tags:

java

retrofit

private interface ResourcesApi {
        @POST("/synchronize")
        void getResources(@Body Map<String, Map<String, Object>> map,
                          Callback<DataModel> callback);
    }

with calling code:

mApi.getResources(data, this);

The class implements Callback so success/failure are defined.

STACKTRACE:

03-09 18:05:15.182  28570-28746/? E/AndroidRuntime﹕ FATAL EXCEPTION: pool-2-thread-1
    java.lang.IllegalStateException: Method getResources not annotated with request type (e.g., GET, POST).
            at retrofit.RestMethodInfo.parseMethodAnnotations(RestMethodInfo.java:179)
            at retrofit.RestMethodInfo.init(RestMethodInfo.java:115)
            at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:327)
            at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:262)
            at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:313)
            at retrofit.CallbackRunnable.run(CallbackRunnable.java:38)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)
like image 955
rodly Avatar asked Dec 25 '22 12:12

rodly


1 Answers

It means the @POST annotation can't be found at runtime. Without the HTTP method type (and relative URL it contains), Retrofit cannot make the request.

Are you using Proguard or another tool to trim "unused" code? If so, instruct it to keep Retrofit's annotations.

like image 183
Jake Wharton Avatar answered May 18 '23 13:05

Jake Wharton