我寫了一個REST post方法,如我的其他question的答案中所述。來自Android的調用節點REST服務
當嘗試使用curl命令後服務工作正常
curl -X POST -H "Content-Type: application/json" -d '{"username":Tom,"mail":"[email protected]"}' http://localhost:3080/accounts/put/
現在我主持,使得它可以通過互聯網訪問的VPS節點應用。其他獲得服務是可訪問的,並且數據正確填充。
如果我試圖執行相同的curl命令它拋出如下錯誤
curl -X POST -H "Content-Type: application/json" -d '{"username":Tom,"mail":"[email protected]"}' http://MyServerIP:3080/accounts/put/
的錯誤是
Cannot call method 'insert' of undefined
at Object.app.get.db.collection.find.accounts [as handle] (/home/balaaagi/nodeapps/meanservice/server.js:62:18)
at next_layer (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/route.js:103:13)
at Route.dispatch (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/route.js:107:5)
at c (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/index.js:195:24)
at param (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/index.js:268:14)
at param (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/index.js:280:16)
at Function.proto.process_params (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/index.js:296:3)
at next (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/index.js:189:19)
at next (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/index.js:166:38)
at next (/home/balaaagi/nodeapps/meanservice/node_modules/express/lib/router/index.js:166:38)
當我嘗試呼叫的POST從Android應用程序我也面臨着同樣的錯誤作爲輸出EntityUtils.toString(resp.getEntity())
我的JSON對象沒有通過/我的VPS託管服務有問題嗎?