改装错误:Android中的500内部服务器错误

改装错误:Android中的500内部服务器错误

问题描述:

上午使用改进为我与服务器的连接,我的应用程序有登录页面和注销页面在登录期间我从文本框中获取值并使用POST请求发送到服务器它工作正常,改装错误:Android中的500内部服务器错误

public void LoginUser(View v) 

{RestAdapter adapter = new RestAdapter.Builder()  
      .setEndpoint(ROOT_URL) 
      .build(); 

    WashAPI api = adapter.create(WashAPI.class); 

    api.LoginUser(



      Email.getText().toString(), 
      Password.getText().toString(), 

      //Creating an anonymous callback 
      new Callback<Response>() { 
       @Override 
       public void success(Response result, Response response) { 
        //On success we will read the server's output using bufferedreader 
        //Creating a bufferedreader object 
        BufferedReader reader = null; 

        //An string to store output from the server 
        String output = ""; 

        try { 
         //Initializing buffered reader 
         reader = new BufferedReader(new InputStreamReader(result.getBody().in())); 

         //Reading the output in the string 
         output = reader.readLine(); 
        } catch (IOException e) { 
         e.printStackTrace(); 
        } 

接口签到

public interface WashAPI { 
@FormUrlEncoded 
@POST("/xxx/yyy/signin") 
public void LoginUser(
     @Field("email") String email, 
     @Field("password") String password, 

     Callback<Response> callback); 

} 

这工作好

我的服务器API登录后返回我一个道理,在signout的时候,我需要发送令牌,所以我的会话得到了体验。

为signout

代码
public void signout(View v) 
{ 
    Log.d("insidetoken",t); 
    RestAdapter adapter = new RestAdapter.Builder() 
      .setEndpoint(ROOT_URL) 
      .build(); 
    SignoutAPI api = adapter.create(SignoutAPI.class); 
      api.signout(t, 
        new Callback<Response>() { 
         @Override 
         public void success(Response result, Response response) { 

          BufferedReader reader = null; 
          String output = ""; 
          try { 
           reader = new BufferedReader(new InputStreamReader(result.getBody().in())); 
           output = reader.readLine(); 
          } catch (IOException e) { 
           e.printStackTrace(); 
          } 

接口signout

public interface SignoutAPI { 
@FormUrlEncoded 
@POST("/xxx/yyy/zzz/signout") 
public void signout(
     @Field("token") String token, 
     Callback<Response> callback); 

}

我的代码是相同的两个登入和SIGOUT

但签到它的工作原理和signout它给了我RETROFIT错误:500内部服务器错误

但使用邮差它工作正常enter image description here

+0

什么问题? –

+0

为什么在注销操作期间发生内部服务器错误? – livemaker

+0

因为在服务器上有错误 –

500内部服务器错误意味着在服务器端的问题,您应该使用邮递员来检查它。

我该死的确定在web服务响应中会出现问题,而不是你的代码在android端出现问题。

+1

有错误... – livemaker

+0

SERVER中的问题是,它需要TOKEN,但有没有令牌 JWTException在JWTAuth.php行295:需要一个令牌 – livemaker

正如评论中所提到的那样,您似乎正在登录服务中执行某些操作,而这些操作并未在退出服务中完成。

要解决此问题,请确保在注销服务时,您正在检查名为token的POST参数。

+0

我不能让你@eric我需要检查? – livemaker

+0

请参阅http://stackoverflow.com/questions/8100634/get-the-post-request-body-from-httpservletrequest –