Retrofit returns error 307, calling web service in android

I have a strange problem. I created an Android application that uses the "Re-equipment Library" to call a web service. I have extensively tested the application on many devices and in the Android version. Everything works fine, except for one : Acer Iconia Tab A500 with Android 4.0.3 (API level: 15). To do this, each time the web service is called, the retooling returns me the following error:

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

I am sure that the code I am right and I can not understand where the problem may be. Any suggestions?

+6
source share
3 answers

Your new phone may not have access to the Internet and / or server. This was not the case with my phone when I received an error.

Hope this helps!

+1
source

Try to make ur application after redirect. here is how to do it

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 .

0
source

I also ran into the same problem, the server redirects to another link when I got to the base link, I resolved it by getting the link to the redirect server, and then hit that URL to access all the other web APIs.

To get a redirect link:

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

Note. In volley, we can use a retry policy because we get this code 307 and can try again in place (redirect the URL).

If anyone has other best solutions to this problem, please let me know ..

0
source

Source: https://habr.com/ru/post/978839/


All Articles