Retrofit returns error 307, calling web service in android
Asked Answered
D

3

6

I have a strange problem. I created an android app that uses Retrofit library for calling a web service. I have widely tested the app, on a lot of devices and Android version. On all works fine, except for one: a Acer Iconia Tab A500 with Android 4.0.3 (API Level: 15). For this one, each time the web service is called, retrofit return me the following error:

11-28 16:08:59.700: W/System.err(4436): retrofit.RetrofitError: 307 Temporary Redirect

I'm sure the code I right, and I can't figure out where can be the problem. Any suggestions?

Duckbill answered 28/11, 2014 at 15:17 Comment(0)
F
1

It could be that your new phone did not have access to the internet and/or the server. That was what was wrong with my phone when I got the error.

Hope this helps!

Fechter answered 26/6, 2015 at 14:51 Comment(0)
B
0

Try making ur application follow redirects. here is how to do that

With OkHttp:

 public static void setFollowRedirects (boolean auto)
 public OkHttpClient setFollowProtocolRedirects(boolean followProtocolRedirects)

With HttpURLConnection:

public static void setFollowRedirects (boolean auto)
public void setInstanceFollowRedirects (boolean followRedirects)

See discussion here.

Bagehot answered 12/3, 2015 at 11:56 Comment(1)
can tell me where to and what to set in OkHttpGuileless
F
0

I was also facing the same issue, server redirects to some other link when I hit to base link,I resolved it by getting the redirect server link and then hit that url to access all other web APIs.

to get redirect link:

String redirectUrl=responseHeaders.get("location");

Note: In volley we can use retry policy as we get this 307 code and can retry on the location(redirect url).

If anyone having any other best solution of this issue please let me know..

Furious answered 2/12, 2016 at 6:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.