0

Actually I am trying to call an Api which is structured like this:

  @POST("book/block-date-time")
    Call<BlockBookingResponse> requestBlock(@Body long catId, TextView fromDate, TextView fromTime, TextView toDate, TextView toTime);

In my OfferFragment.java class I made a request like this:

 RetroFitFactory.getRetrofitCallFor(RedeemService.class)
                                        .requestBlock(catId, fromDate, fromTime, toDate, toTime)//this line throws the exception
                                        .enqueue(new Callback<BlockBookingResponse>() {
                                            @Override
                                            public void onResponse(@NonNull Call<BlockBookingResponse> call, @NonNull Response<BlockBookingResponse> response) {
                                                if (response.isSuccessful() && response.body() != null) {
                                                    progressDialog1.dismiss();
                                                    Toast.makeText(getContext(), response.body().getMessage(), Toast.LENGTH_SHORT).show();
                                                    startActivity(new Intent(getContext(), BlockList.class));

                                                } else {
                                                    progressDialog1.dismiss();
                                                    Toast.makeText(getContext(), "Fail to block", Toast.LENGTH_SHORT).show();
                                                }
                                            }

                                            @Override
                                            public void onFailure(@NonNull Call<BlockBookingResponse> call, @NonNull Throwable t) {
                                                Toast.makeText(getContext(), "Network Error...", Toast.LENGTH_SHORT).show();

                                            }
                                        });

And to solve this exception I follow this link

but didn't understand it properly, I tried everything (Like I used different annotations like @Body, @field, etc) but it still throws this Exception:

    java.lang.IllegalArgumentException: No Retrofit annotation found. (parameter #2)

Any help on how to resolve this.Great help

Community
  • 1
  • 1

1 Answers1

0

Do not use TextView as argument to the retrofit API since TextView is android object and won't be sent to the server. Instead extract the TextView value and send that. Of course you have to add other annotations so Retrofit knows how to send the values as

Amit Sharma
  • 164
  • 1
  • 4