Json Post导致错误422

时间:2016-05-20 03:08:59

标签: android ruby-on-rails devise android-volley

我正在使用设计从Android应用程序登录,但在尝试登录时收到错误422。我正在使用排球将json发布到rails服务器, 这是会话控制器的代码

def create
  self.resource = warden.authenticate!(auth_options)
  set_flash_message(:notice, :signed_in) if is_flashing_format?
  sign_in(resource_name, resource)
  yield resource if block_given?
  respond_with resource, :location => after_sign_in_path_for(resource) do            |format|
    format.json {render :json => {:success => true} } # this code will get executed for json request
  end
end

这是我在android

中的登录请求
    public LoginRequest(String email, String password, Response.Listener<String> listener){

    super(Method.POST, LOGIN_REQUEST_URL, listener, null);
    params = new HashMap<>();
    params.put("email", email);
    params.put("password", password);

    new Response.ErrorListener(){

        @Override
        public void onErrorResponse(VolleyError volleyError){

            try{
                String responseBody = new String(volleyError.networkResponse.data, "utf-8");
                JSONObject jsonObject = new JSONObject(responseBody);

            }catch (JSONException e){

            }catch (UnsupportedEncodingException e){

            }
        }
    };

0 个答案:

没有答案