我使用sails.js v0.11.1通過請求主體藍圖動作模型。 在我routes.js文件我有這樣的路線寫:綁定Sails.js路線
'POST /user' : {
model: 'user',
blueprint: 'create'
},
我的身體發送POST請求(通過postman),以/user
與此:
{
userName : "firstUser",
password : "secretPwd5779",
firstName : "William",
lastName : "Askey"
}
,但我得到這個迴應:
{
"error": "E_VALIDATION",
"status": 400,
"summary": "4 attributes are invalid",
"model": "User",
"invalidAttributes": {
"userName": [
{
"rule": "string",
"message": "`undefined` should be a string (instead of \"null\", which is a object)"
},
{
"rule": "required",
"message": "\"required\" validation rule failed for input: null"
}
],
"password": [
{
"rule": "string",
"message": "`undefined` should be a string (instead of \"null\", which is a object)"
},
{
"rule": "required",
"message": "\"required\" validation rule failed for input: null"
}
],
"firstName": [
{
"rule": "string",
"message": "`undefined` should be a string (instead of \"null\", which is a object)"
},
{
"rule": "required",
"message": "\"required\" validation rule failed for input: null"
}
],
"lastName": [
{
"rule": "string",
"message": "`undefined` should be a string (instead of \"null\", which is a object)"
},
{
"rule": "required",
"message": "\"required\" validation rule failed for input: null"
}
]
}
}
根據Sails.js documentation我寫了正確的路線。
通過URL參數,使這一請求(即發出請求到/user?userName=firstUser&password=secretPwd5779&firstName=William&lastName=Askey
作品就好了我如何能得到這個無需通過URL參數發送數據的工作
您能不能告訴我們的頁面(表單),JavaScript的,你發佈的數據? – num8er
我使用REST客戶郵差(https://www.getpostman.com)提出這項要求 – Xecure