我想将改造连接到我的本地主机

时间:2019-09-14 17:17:33

标签: android asp.net localhost retrofit

我构建了一个asp.net Web API,我想从Android应用程序获取和发布请求  所以我使用了改造,但是我不知道如何将改造连接到我的本地主机

当我将本地主机地址放在base_url中时,我报错了

在这里我做了一个界面

我做了改造实例类

我尝试放置localhost和10.0.2.2

错误是 “找不到证书路径的信任锚”

我该怎么办?!

我也想知道我应该在@GET(----)中键入什么  在界面中调用列表之前

这是我的代码

package com.example.apitest;


import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

public class RetrofitInstance {

    private static Retrofit retrofit;
    private static final String BASE_URL = "https://localhost:44349/api/";

    /**
     * Create an instance of Retrofit object
     * */
    public static Retrofit getRetrofitInstance() {
        if (retrofit == null) {
            retrofit = new retrofit2.Retrofit.Builder()
                    .baseUrl(BASE_URL)
                    .addConverterFactory(GsonConverterFactory.create())
                    .build();
        }
        return retrofit;
    }
}


    package com.example.apitest;

    import retrofit2.Call;
    import retrofit2.http.GET;

    public interface GetUserDataService {
        @GET("api/users/")
        Call<UserList> getUserData();
    }

0 个答案:

没有答案