2016-11-24 18 views
0

私のコードで何が問題になっていないのですか?ヘッダーとパラメータを含むボレーリクエストを送信します。パラメータのフォーマットは "application/x-www-form-urlencoded"になります。VOLLEY 500と400 error

私はこのコード

 @Override 
     public Map<String, String> getHeaders() throws AuthFailureError { 
      Map<String, String> params = new HashMap<String, String>(); 
      params.put("Token", "1234); 
      params.put("Content-Type", "application/x-www-form-urlencoded"); 
      return params; 
     } 

を使用して、私はこのコード

@Override 
    public Map<String, String> getHeaders() throws AuthFailureError { 
     Map<String, String> params = new HashMap<String, String>(); 
     params.put("Token", "1234); 
     return params; 
    } 

と全体の機能を使用していたときに500エラーを取得しています400エラーが発生している取得しています

public void requestWithSomeHttpHeaders() { 

    RequestQueue queue = Volley.newRequestQueue(this); 

    StringRequest postRequest = new StringRequest(Request.Method.POST,"http://12.211.156.201/SOWebService/Service.asmx/GetCompany", 
      new Response.Listener<String>() 
      { 
       @Override 
       public void onResponse(String response) { 
        System.out.println(response); 

       } 
      }, 
      new Response.ErrorListener() 
      { 
       @Override 
       public void onErrorResponse(VolleyError error) { 

        System.out.println(error.toString() + "--" + error.getCause()); 

        // TODO Auto-generated method stub 
        Log.d("ERROR","error => "+error.toString()); 
        // definitions.setText("check your internet connection"); 
        if (error instanceof TimeoutError || error instanceof NoConnectionError) { 
         System.out.println("1"); 
        } else if (error instanceof AuthFailureError) { 
         System.out.println("2"); 
         //TODO 
        } else if (error instanceof ServerError) { 
         System.out.println("3"); 
         //TODO 
        } else if (error instanceof NetworkError) { 
         System.out.println("4"); 
         //TODO 
        } else if (error instanceof ParseError) { 
         System.out.println("5"); 
         //TODO 
        } 
       } 
      } 
    ) 

    { 
     @Override 
     public Map<String, String> getHeaders() throws AuthFailureError { 
      Map<String, String> params = new HashMap<String, String>(); 
      params.put("Token", token); 
      return params; 
     } 

     @Override 
     protected Map<String, String> getParams() throws AuthFailureError { 
      // return super.getParams(); 
      Map<String, String> params = new HashMap<String, String>(); 
      params.put("groupName", "avd"); 
      params.put("userCode", "ADMIN"); 

      return params; 
     } 

    }; 
    queue.add(postRequest); 

} 

答えて