Android Retrofit 附加不需要的字符

标签 android json retrofit2

我正在尝试对 json 文件执行 GET 请求:

https://www.someurl.com/appconfiguration.json

所以我用下面的 GET 方法创建了一个接口(interface)

  @GET("appconfiguration.json}")
  Call<AppConfigParent> loadAppConfigParent();

并这样调用它:

   final MMSATServices.AppConfigResponse appConfigResponse = new MMSATServices.AppConfigResponse();
    appConfigResponse.appConfigParent = new AppConfigParent();
    appConfigResponse.appConfigParent.configuration = null;

    Call<AppConfigParent> call = api.loadAppConfigParent();
    call.enqueue(new Callback<AppConfigParent>() {
        @Override
        public void onResponse(Call<AppConfigParent> call, Response<AppConfigParent> response) {
            appConfigResponse.appConfigParent.configuration = response.body().configuration;
            bus.post(appConfigResponse);
        }

        @Override
        public void onFailure(Call<AppConfigParent> call, Throwable t) {

        }
    });

请注意,api 对象是接口(interface)的实例,它是在父类(super class)中定义的。

实际问题是我收到 404 响应:

请求{method=GET, url= https://someurl.com/appconfiguration.json%7D , 标签=请求{方法=GET, url= https://someurl.com/appconfiguration.json%7D , 标签=空}}

如您所见,%7D 附加到 URL,这会导致 404 错误。我怎样才能摆脱这种行为?

最佳答案

删除@GET("appconfiguration.json}")

关于Android Retrofit 附加不需要的字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43116411/

相关文章:

php - 将连接结果映射为相关行下的数组

android - 使用 Retrofit2 的 HTTP 请求得到 "CLEARTEXT communication not supported"错误

android - 对于 204 无内容响应,Retrofit2 在 kotlin 中返回 null Unit

java - 从 java 扩展时,静态函数在 kotlin 中不可见

android - 为什么设置了HandlerThread looper的Handler可以和UI Object交互?

Android 的 Activity == Windows 的模态对话框?

JSON 和 Cygwin - 如何解析、获取字段等

android - 在 Android 上保持 TensorFlow 模型加密

java - android volley json解析器错误

android - 改造2中的响应{协议(protocol)= http/1.1,代码= 404,消息=未找到,url = https://sub.domain.com}