retrofit2中关于baseUrl问题(二)

http://op.juhe.cn/onebox/basketball/nba?key=98020a1e920819b8ff4fcfbdd7747f8c

组合一://失败
baseUrl("http://op.juhe.cn/onebox/basketball/nba?key=98020a1e920819b8ff4fcfbdd7747f8c/")
@GET("/")
Observable getNBA(); 

组合二://失败
baseUrl("http://op.juhe.cn/onebox/basketball/nba/")
@GET("/")
Observable getNBA1(@Query("key") String key);  //失败

组合三://成功
baseUrl("http://api.m.mtime.cn/")
@GET("onebox/basketball/nba?key=98020a1e920819b8ff4fcfbdd7747f8c")  
Observable getNBA2();

组合四://成功
baseUrl("http://op.juhe.cn/")
@GET("onebox/basketball/nba")
Observable getNBA3(@Query("key") String key);
public void getNBA() {

        Retrofit retrofit = new Retrofit.Builder()
//                .baseUrl("http://op.juhe.cn/")
                .baseUrl("http://op.juhe.cn/onebox/basketball/nba/")
//                .baseUrl("http://op.juhe.cn/onebox/basketball/nba?key=98020a1e920819b8ff4fcfbdd7747f8c/")
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        PBikeService service = retrofit.create(PBikeService.class);
        service
//                .getNBA()
                .getNBA1("98020a1e920819b8ff4fcfbdd7747f8c")
//                .getNBA3()
//                .getNBA3("98020a1e920819b8ff4fcfbdd7747f8c")
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Consumer() {
                    @Override
                    public void accept(@NonNull NBA nba) throws Exception {
                        Log.e("FirstActivity", nba.getReason());
                        text.setText(nba.getReason());
                    }
                }, new Consumer() {
                    @Override
                    public void accept(@NonNull Throwable throwable) throws Exception {
                        text.setText(throwable.getMessage().toString());
                    }
                });
    }

PBikeService

    @GET("/")
    Observable getNBA();  //失败

    @GET("/")
    Observable getNBA1(@Query("key") String key);  //失败

    @GET("onebox/basketball/nba?key=98020a1e920819b8ff4fcfbdd7747f8c")  //成功
    Observable getNBA2();

    @GET("onebox/basketball/nba")
    Observable getNBA3(@Query("key") String key);

你可能感兴趣的:(retrofit2中关于baseUrl问题(二))