-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
call.enqueue - Api endpoint is called 2 times implicitly #1242
Comments
Had the same issue. Thank you so much for posting it here. |
What did you do to make only one request? |
I had an HTTPLogger and chain.proceed(..) in one interceptor itself. So assuming that HTTPLogger internally also calls chain.proceed() which thus makes two requests, I added a networkinterceptor and moved the HTTPLogger to the network interceptor and my custom apikey chain.proceed(...) In other interceptor. Which worked as a charm and the API was called only once internally. Thus you need to look for code which can possibly call the chain.proceed(..) method internally. Which makes a new request. |
#2761 |
Can any body post code Solution for same |
any who come after, the solution for me was to remove chain.proceed calls leave only the one that add the header long story short chain.proceed create another request maybe |
@shahsurajk Thanks save me a lot of trouble |
Output in Android Studio
If I use Postman (REST Client) to call the api endpoint, its called only once. But with the above code, when executed once, the api endpoint is called twice.
I am trying to format the received data in normal com.google.gson.JsonObject as I don't need the hassles of maintaing Models in Android code.
What's more weird is, first 'Calling REST' gets onto console. Then 2 requests are made and only after second request, 'REST Response : {"status":"success"}' gets onto console.
I am using Retrofit 2.0.0-beta2.
Edit - My Bad, the interceptor fired another request, hence it was being called 2 times.
The text was updated successfully, but these errors were encountered: