无法发布,无法从android到达nodejs

时间:2015-07-08 13:32:01

标签: android node.js

我无法从androiapp端点到达我的nodejs服务器。 问题是,我可以从其他人那里获得,但不是来自新的。

从这个网址我可以到达:

            ApiClient.post("/v1/forgot", params,
                    new AsyncHttpResponseHandler() {

                        @Override
                        public void onFailure(int arg0, Header[] arg1,
                                byte[] arg2, Throwable arg3) {
                            userMessage=("Password NOT RESET.\n Please check the email entered,\n"+userEmailEntered+"\nor try again later.");
                            Toast.makeText(getApplicationContext(), userMessage, Toast.LENGTH_LONG).show();
                        }

                        @Override
                        public void onSuccess(int arg0, Header[] arg1,
                                byte[] resp) {
                            String response = new String(resp);
                            try {
                                JSONArray jsonArray=new JSONArray(response);
                                String json = jsonArray.getJSONObject(0).toString();
                                final ResetPasswordResponse resetPasswordResponse = JsonUtils.parseJson(json, ResetPasswordResponse.class);

                                if (resetPasswordResponse.getStatus().equals("sent")){
                                userMessage=("Reset instructions sent to "+resetPasswordResponse.getEmail());
                                }else{
                                    userMessage=("The email account entered "+resetPasswordResponse.getEmail()+" is not recognized. Please check the email address entered");
                                }
                                Toast.makeText(getApplicationContext(), userMessage, Toast.LENGTH_LONG).show();

                            } catch (JSONException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }

                        }

            });

但是我不能从新的资源中发布我创造的内容:

    Log.i("store", devRegId.toString());

    //TODO PROBLEM TO SEND REGISTRATION - cannot post
    ApiClient.post("/v1/device", params,new AsyncHttpResponseHandler(){

        @Override
        public void onSuccess(int statusCode, Header[] headers, byte[] resp) {
            String response = new String(resp);
            Log.i("store", response);
        }

        @Override
        public void onFailure(int statusCode, Header[] headers, byte[] resp, Throwable error) {
            Log.i("store", "NOT ok");
            Log.i("store", resp.toString());

            String response = new String(resp);
            Log.i("store", response);
        }
    });

它是client.post创建的:

private static AsyncHttpClient client = new AsyncHttpClient();

 public static void post(String url, RequestParamsCustom params, AsyncHttpResponseHandler responseHandler) {

        client.post(getAbsoluteUrl(url), params, responseHandler);
    }

服务器路由:

app.post('/v1/device', function(req,res) {

    gcmDeviceRouter.storeDevice(req,res)

});

服务器运行正常,我可以从其他终端(网络应用程序,邮差工具)访问。

这是错误:

debug I / store:NOT ok

debug I / store:[B @ 235ae686

debug I / store:无法POST / v1 / device

感谢您的帮助

0 个答案:

没有答案