2016-12-11 2 views
0

저는 Postman에서 잘 작동하는 API를 실행하고 있지만 발리를 통해 서버 오류가 발생하면이를 실행하고 있습니다.발리 서버 문제

응답 : com.android.volley.ServerError

이죠 잘 작동 :

enter image description here

코드 :

public void postNewComment(Context context){ 
        String url =  public static final String BASE_URL = "http://api.haebix.in/v1/register"; 

      RequestQueue queue = Volley.newRequestQueue(context); 
      StringRequest sr = new StringRequest(Request.Method.POST,url, new Response.Listener<String>() { 
       @Override 
       public void onResponse(String response) { 
        Log.d(TAG,response.toString()); 

       } 
      }, new Response.ErrorListener() { 
       @Override 
       public void onErrorResponse(VolleyError error) { 
        Log.d("Error.Response", error.toString()); 

       } 
      }){ 
       @Override 
       protected Map<String,String> getParams(){ 
        Map<String,String> params = new HashMap<String, String>(); 
        params.put("signup_type", "normal"); 
        params.put("name", name); 
        params.put("email", emailID); 
        params.put("password", password); 
        params.put("mobile_no", phoneNo); 
        params.put("promo_code", promocode); 
        params.put("dob", ""); 
        params.put("gender", ""); 
        params.put("address", ""); 
        params.put("city", ""); 
        params.put("state", ""); 
        params.put("pincode", ""); 
        return params; 
       } 

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

나에게 t을 도와주세요 o 내 실수를 찾아라.

+0

getBody' 대신'의'사용해보십시오 getParams' – BNK

+0

을 @BNK 같은 에러. 서버 상태 코드가 400 –

+0

'getHeaders' 안에'params.put ("Content-Type", "application"대신에'params.put ("Content-Type", "application/json");/x-www-form-urlencoded "); – BNK

답변

1

재 작성 URL을 도울 수 있음 : 문자열 URL = "http://api.haebix.in/v1/register"을;

나는 응답 점점 오전 : { "오류"거짓 "API_KEY": "b020bcc9a20c714f2e61c971a9ccd24c", "메시지": "당신은 성공적으로 등록되어있다"}

+0

감사합니다. –

0

RequestQueue queue = Volley.newRequestQueue (context);

그래서 그것은

RequestQueue 큐 Volley.newRequestQueue = (문맥)된다

(SR)

queue.add을 수행하기 전에이 라인을 추가;

queue.add (SR)

는 아래와 같이

+0

시도! 작동하지 않음 –