Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IllegalArgumentException: @Url cannot be used with @GET URL (parameter #1)

@GET("user/token/")
Observable<String> gToken(@Url String url, @Query("usertype") int userType);

I get the following error:

Process: com.gouhuoapp.say, PID: 12519
rx.exceptions.OnErrorNotImplementedException: @Url cannot be used with @GET URL (parameter #1)
    for method ApiService.getToken
    at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:386)
    at rx.internal.util.InternalObservableUtils$ErrorNotImplementedAction.call(InternalObservableUtils.java:383)
    at rx.internal.util.ActionSubscriber.onError(ActionSubscriber.java:44)
    at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:153)
    at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:115)
    at rx.exceptions.Exceptions.throwOrReport(Exceptions.java:216)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:139)
    at rx.observers.SerializedObserver.onNext(SerializedObserver.java:91)
    at rx.observers.SerializedSubscriber.onNext(SerializedSubscriber.java:94)
    at rx.internal.operators.OperatorTakeUntil$1.onNext(OperatorTakeUntil.java:45)
    at rx.internal.operators.OperatorThrottleFirst$1.onNext(OperatorThrottleFirst.java:53)
    at com.jakewharton.rxbinding.view.ViewClickOnSubscribe$1.onClick(ViewClickOnSubscribe.java:23)
    at android.view.View.performClick(View.java:4909)
    at android.view.View$PerformClick.run(View.java:20390)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:192)
    at android.app.ActivityThread.main(ActivityThread.java:5784)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
 Caused by: java.lang.IllegalArgumentException: @Url cannot be used with @GET URL (parameter #1)
    for method ApiService.getToken
    at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:720)
    at retrofit2.ServiceMethod$Builder.methodError(ServiceMethod.java:711)
    at retrofit2.ServiceMethod$Builder.parameterError(ServiceMethod.java:729)
    at retrofit2.ServiceMethod$Builder.parseParameterAnnotation(ServiceMethod.java:367)
    at retrofit2.ServiceMethod$Builder.parseParameter(ServiceMethod.java:333)
    at retrofit2.ServiceMethod$Builder.build(ServiceMethod.java:202)
    at retrofit2.Retrofit.loadServiceMethod(Retrofit.java:166)
    at retrofit2.Retrofit$1.invoke(Retrofit.java:145)
    at java.lang.reflect.Proxy.invoke(Proxy.java:397)
    at $Proxy3.getToken(Unknown Source)
    at com.gouhuoapp.say.data.DataManager.getToken(DataManager.java:83)
    at com.gouhuoapp.say.view.activity.RegisterMobileActivity.getQiniuToken(RegisterMobileActivity.java:171)
    at com.gouhuoapp.say.view.activity.RegisterMobileActivity.lambda$initTitle$4(RegisterMobileActivity.java:153)
    at com.gouhuoapp.say.view.activity.RegisterMobileActivity$$Lambda$7.call(Unknown Source)
    at rx.internal.util.ActionSubscriber.onNext(ActionSubscriber.java:39)
    at rx.observers.SafeSubscriber.onNext(SafeSubscriber.java:134)
        ... 15 more
like image 227
woniu Avatar asked Dec 15 '16 16:12

woniu


1 Answers

The error means exactly what it says, you can use GET(...) or @Url on a parameter, but not both at the same time. If you need to use @Url, remove the url from the @GET annotation. You will need to add the part of the url you had in the into your url parameter.

@GET
Observable<String> gToken(@Url String url, @Query("usertype") int userType);
like image 92
iagreen Avatar answered Nov 10 '22 07:11

iagreen