与老学校改造服务 [英] Retrofit with an old school service

查看:141
本文介绍了与老学校改造服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是外部服务,如:
<一href=\"http://domain.com/free/v1/servicename.ext?format=json&num_of_days=4\">http://domain.com/free/v1/servicename.ext?format=json&num_of_days=4

I'm using an external service like : http://domain.com/free/v1/servicename.ext?format=json&num_of_days=4

我尝试使用改造这样的:

I try to use Retrofit like that :

@GET("/free/v1/servicename.ext?format=json&num_of_days={numOfDays}")
void serviceName(@Path("numOfDays") int numOfDays, Callback<Result> callback);

但会抛出异常:

URL query string must not have replace block.

它是用这种URL的兼容?

Is it compatible with this kind of url ?

推荐答案

这绝对是与之兼容!

您不能使用 @Path 查询参数的内部。这注释是只为路径内的替代品。

You can't use @Path inside of the query parameters. That annotation is only for replacements inside the path.

@Query 参数允许创建动态查询参数。

The @Query parameter allows for creating dynamic query parameters.

@GET("/free/v1/servicename.ext?format=json")
void serviceName(@Query("num_of_days") int numOfDays, Callback<Result> callback);

这篇关于与老学校改造服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆