I've created a model (slc loopback:model customer), done 'slc run', and browsed to http://localhost:3000/explorer/. I see both 'customer' and 'User' models. But I cannot figure out how to add an instance to the User model. I select 'Users->Post /Users' and provide the following data
{
"realm": "",
"username": "myname",
"credentials": "secret",
"challenges": [],
"email": "[email protected]",
"emailVerified": false,
"verificationToken": "",
"status": "",
"created": "",
"lastUpdated": "",
"id": 0
}
The response is
{
"error": {
"name": "ValidationError",
"status": 422,
"message": "The `User` instance is not valid. Details: `password` can't be blank (value: undefined).",
"statusCode": 422,
"details": {
"context": "User",
"codes": {
"password": [
"presence"
]
},
"messages": {
"password": [
"can't be blank"
]
}
},
"stack": "ValidationError: The `User` instance is not valid. Details: `password` can't be blank (value: undefined).
}
I've tried with other values for the data but cannot figure out how to resolve the 'blank password'. Can anyone point out what I might be missing? Thanks in advance.
You need to provide a password
key (even though it's not listed). Do the same POST /User
, but enter these fields in the JSON object instead:
{
email: "[email protected]",
password: "foobar"
}
These two specifically are required. The rest of the ones you've shown are optional.