Issue
I am getting 500 from response but in postman its showing 200
response that I am getting in body
My ApiInterface
@Streaming
@GET("SaleReport")
@Headers({"Content-Type: application/pdf"})
Call<ResponseBody> getReport(@Header("Authorization") String token, @Query("SaleId") String saleId);
Retrofit Call
private void getSalesReport(String saleId) {
if (saleId != null) {
Toast.makeText(this, "" + saleId, Toast.LENGTH_SHORT).show();
ApiClient.getInstance(this).getApi().getReport("Bearer " + Constant.Token, saleId)
.enqueue(new Callback<ResponseBody>() {
@Override
public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
if (response.isSuccessful()) {
Log.e("PDF","Success");
} else {
Log.e("PDF",""+response.code());
}
}
@Override
public void onFailure(Call<ResponseBody> call, Throwable t) {
Log.e("PDF", "" + t.toString());
}
});
} else {
Toasty.error(getApplicationContext(), "SaleId Required", Toasty.LENGTH_SHORT).show();
}
}
Solution
It's a back-end side issue.... They need session to access the pdf. Although I have solved it by sending a session from previous request and sent it as a header.
Answered By - Iftakher Hasan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.