Android 改装post请求返回405错误

Android 改装post请求返回405错误,android,post,retrofit,Android,Post,Retrofit,我不太会使用翻新库。我需要写一个方法,将注册用户 Api如下所示: 职位 它包含4个字段 fio-字符串 电子邮件字符串 电话串 密码字符串 响应示例: { "result": { "code": 200, "token": "fcac1a3b62cb51374123de565dc12e16" } } 这是我的客户端类: package com.example.bydlokoder.mobigeartest.activities.utils;

我不太会使用翻新库。我需要写一个方法,将注册用户

Api如下所示:

职位 它包含4个字段

  • fio-字符串
  • 电子邮件字符串
  • 电话串
  • 密码字符串
  • 响应示例:

    {
        "result": {
            "code": 200,
            "token": "fcac1a3b62cb51374123de565dc12e16"
        }
    }
    
    这是我的客户端类:

    package com.example.bydlokoder.mobigeartest.activities.utils;
    
    import retrofit.Callback;
    import retrofit.http.Body;
    import retrofit.http.POST;
    
    public class BlaBlaClient {
        public static final String API_URL = "http://blablabla.com/";
    
        public interface Service {
            @POST("/user")
            void createUser(@Body User user, Callback<Result> callback);
        }
    }
    
    它是应用于创建请求的用户类:

    public class User {
    
        public User(String fio, String email, String phone, String password) {
            this.fio = fio;
            this.email = email;
            this.phone = phone;
            this.password = password;
        }
    
        private String fio;
        private String email;
        private String phone;
        private String password;
    
        public String getFio() {
            return fio;
        }
    
        public String getEmail() {
            return email;
        }
    
        public String getPhone() {
            return phone;
        }
    
        public String getPassword() {
            return password;
        }
    }
    
    为什么要用Body注释“user”?web API需要JSON序列化输入还是URL编码?
    public class User {
    
        public User(String fio, String email, String phone, String password) {
            this.fio = fio;
            this.email = email;
            this.phone = phone;
            this.password = password;
        }
    
        private String fio;
        private String email;
        private String phone;
        private String password;
    
        public String getFio() {
            return fio;
        }
    
        public String getEmail() {
            return email;
        }
    
        public String getPhone() {
            return phone;
        }
    
        public String getPassword() {
            return password;
        }
    }