Java 改装响应{protocol=h2,code=404,message=,url=https://myurl/api/}

Java 改装响应{protocol=h2,code=404,message=,url=https://myurl/api/},java,android,retrofit,retrofit2,server-response,Java,Android,Retrofit,Retrofit2,Server Response,我使用Reformation2发送请求,但作为响应,我得到以下错误 响应{protocol=h2,code=404,message=,url=} 在这里,我将我的基本url传递给请求 静态最终字符串BASE_URL=“” 这是我的控制器类 private static Retrofit retrofit; public static Retrofit getClient() { if (retrofit == null) { retrofit = new Retrofi

我使用Reformation2发送请求,但作为响应,我得到以下错误

响应{protocol=h2,code=404,message=,url=}

在这里,我将我的基本url传递给请求

静态最终字符串BASE_URL=“”

这是我的控制器类

private static Retrofit retrofit;

public static Retrofit getClient() {
    if (retrofit == null) {
        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
    return retrofit;
}
这是我的界面。 在这里,我使用map传递带有参数和标题的主体

public interface AddProductApi {

    @FormUrlEncoded
    @POST("api/")
    Call<BodyOfAddPro> loadChanges(@FieldMap Map<String,String> body, 
@HeaderMap Map<String, String> header);
}
公共接口AddProductApi{
@FormUrlEncoded
@POST(“api/”)
调用loadChanges(@FieldMap-body,
@标题映射标题);
}
这是我的api调用函数 这里我传递参数以获得响应。我得到了上面显示的错误响应

private void retroApiCall() {

    addProductApi = Controller.getClient().create(AddProductApi.class);

Map<String, String> addproductParams = new HashMap<String,String>();
addproductParams.put("UserID", sharedpreferences.getString("UserID", 
""));
    addproductParams.put("CategoryID", subsubCategoryID);

   addproductParams.put("ProductPrice",productPrice.getText().toString());
   addproductParams.put("DeliveryTime",Time.getText().toString();
   addproductParams.put("ProductType",itemCondition.getText().toString());
   addproductParams.put("OutOfStock", outofStock);
   addproductParams.put("IsActive", "1");


    Log.e("body",addproductParams.toString());

    Map<String, String> header = new HashMap<>();
    header.put("Verifytoken", sharedpreferences.getString("ApiToken",""));

    Log.e("header", header.toString());

    Call<BodyOfAddPro>call1
    =addProductApi.loadChanges(addproductParams,header);
    call1.enqueue(new Callback<BodyOfAddPro>() {
        @Override
        public void onResponse(Call<BodyOfAddPro> call, 
retrofit2.Response<BodyOfAddPro> response) {
            BodyOfAddPro loginResponse = response.body();

            Log.e("retroresponse", "Response 1 --> " + response);

        }

        @Override
        public void onFailure(Call<BodyOfAddPro> call, Throwable t) {
            Log.e("retroresponseerror", "Response 1 --> " + 
t.getMessage());

   }
    });

}
private void retroApiCall(){
addProductApi=Controller.getClient().create(addProductApi.class);
Map addproductParams=new HashMap();
addproductParams.put(“UserID”),SharedReferences.getString(“UserID”,
""));
addproductParams.put(“CategoryID”,SubCategoryId);
addproductParams.put(“ProductPrice”,ProductPrice.getText().toString());
addproductParams.put(“DeliveryTime”,Time.getText().toString();
addproductParams.put(“ProductType”,itemCondition.getText().toString());
addproductParams.put(“OutOfStock”,OutOfStock);
addproductParams.put(“IsActive”、“1”);
Log.e(“body”,addproductParams.toString());
Map header=newhashmap();
header.put(“Verifytoken”,SharedReferences.getString(“ApiToken”,“”));
Log.e(“header”,header.toString());
呼叫1
=addProductApi.loadChanges(addproductParams,标头);
call1.enqueue(新回调(){
@凌驾
公共void onResponse(调用,
(2.回应){
BodyOfAddPro loginResponse=response.body();
Log.e(“回复”、“回复1-->”+回复);
}
@凌驾
失败时公共无效(调用调用,可丢弃的t){
Log.e(“retroresponseerror”,“响应1-->”+
t、 getMessage());
}
});
}

正在寻找答案。!

复制收到的带有错误的url,并尝试与postman一起使用,检查是否达到了预期的终点。在postman上工作正常。尝试将基本url替换为(不以正斜杠结尾)并将该正斜杠添加到AddProductApi中端点的开头。不使用此解决方案最终url应该是什么样子的?复制收到的带有错误的url并尝试与postman一起使用,检查您是否使用它达到了预期的端点。在postman上工作正常。尝试将基本url替换为(不以正斜杠结尾)并将该正斜杠添加到AddProductApi中端点的开头。不使用此解决方案最终url应该是什么样子?