【问题标题】:retrofit using more than one variable in @path在@path 中使用多个变量进行改造
【发布时间】:2015-11-19 22:54:12
【问题描述】:

我正在尝试使用 URL 中的多个变量发送请求,如下代码所示

@GET("rides/getride/{user}/{lat_orig}%2C{lon_orig}/{lat_dest}%2C{lon_dest}/")
        Call<User> getride(@Path("user") String user,@Path("lat_orig") double lat_orig,@Path("long_orig") double lon_orig,
                @Path("lat_dest") double lat_dest,@Path("lon_dest") double lon_dest);

但它给我一个错误。还有另一种方法吗? 我要一个一个输入然后一起发送吗?

【问题讨论】:

  • 你遇到了什么错误?

标签: android http url retrofit


【解决方案1】:

错误消息确实可以帮助指导问题所在。你得到的错误是 -

网址“rides/getride/{user}/{lat_orig}%2C{lon_orig}/{lat_dest}%2C{lon_dest}/”不包含“{long_orig}”。 (参数#3)

从中,我们可以看到问题在于您的网址中您有“lon_orig”(没有 g),而在您的 Path 注释中您有 - “long_orig”(有 g)。更改其中一个或另一个以使其匹配。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-07
    • 2016-01-18
    • 2020-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多