【问题标题】:Android : Retrofit and using dynamic URLSAndroid:改造和使用动态 URL
【发布时间】:2015-02-20 21:14:45
【问题描述】:

早上好。我对改造很陌生,从另一个人那里接手这个项目。我们需要与在每次调用的 url 中使用代码的 API 交谈 例如http://www.example.com/CODE/review

我想我会尝试显而易见的,但 Retrofit 抱怨 属性值必须是常量

public interface ApiService{
        public static final String ref = getRefCode();

        //TODO: Use ref number to identify users
        @Headers({
                "Accept: application/json",
                "Content-Type: application/json"})
        @GET("/" + ref + "/RepairStatus")
        void getRepairStatus(@Header("If-None-Match") String ifNoneMatch, RestCallback<RepairStatusResponse> callback);


        @Headers({
                "Accept: application/json",
                "Content-Type: application/json"})
        @POST("/" + ref + "/Review")
        void postReview(@Body ReviewRequest reviewRequest);

    }

对不起,如果我错过了明显的:)

【问题讨论】:

  • 你不要这样做:@GET("/group/{id}/users") List groupList(@Path("id") int groupId);跨度>
  • 你答对了,请发帖

标签: android retrofit


【解决方案1】:

你不要这样做:

@GET("/group/{id}/users") List<User> groupList(@Path("id") int groupId);

【讨论】:

    猜你喜欢
    • 2014-11-24
    • 1970-01-01
    • 1970-01-01
    • 2015-12-10
    • 2023-03-16
    • 2016-12-09
    • 1970-01-01
    相关资源
    最近更新 更多