square / retrofit

A type-safe HTTP client for Android and the JVM
https://square.github.io/retrofit/
Apache License 2.0
42.96k stars 7.3k forks source link

retrofit2.adapter.rxjava.HttpException: HTTP 404 Not Found #2019

Closed zeshaoaaa closed 7 years ago

zeshaoaaa commented 7 years ago
private ApiWrapper() {

        LogUtils.e("ApiWrapper---baseUrl:" + BASE_URL);

        HttpLoggingInterceptor logging = new HttpLoggingInterceptor();
        logging.setLevel(HttpLoggingInterceptor.Level.BODY);

        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
                .readTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
                .addInterceptor(logging)
                .build();

        retrofit = new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .client(okHttpClient)
                .build();
    }
@POST("/Business/QuickInventory")
 Observable<Result<User>> quickInventory(
            @Query("jsonParam") String jsonParam,
            @Query("userParam") String userParam,
            @Query("sign") String sign);
ApiWrapper.getInstance()
                .create(InventoryApi.class)
                .quickInventory(JSONUtils.obj2json(inventoryItems), JSONUtils.obj2json(inventoryUser), sigh)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(getInventorySubscriber());

When the inventoryItems have 22 item, the API work well. But when the inventoryItems over 22, it's not work. The problem is parameter too long my backed developer said. Sorry for my bad English. Thanks your help.

How can it fix it?

JakeWharton commented 7 years ago

Consider using @FormUrlEncoded and @FIeld so that the contents are posted in the request body instead of the URL. That requires your server to support this mechanism though.

This isn't a Retrofit issue. Please ask future usage questions on StackOverflow using the 'retrofit' tag.