I am building an Angular app that uses a REST API built from NodeJS and LoopBack. When trying to create new records, I'm getting a weird error both from my app and also in Postman. (Property names have been changed to protect the innocent)
The `ObjectName` instance is not valid.
Details: `id` can't be blank (value: undefined);
`property2` can't be blank (value: undefined);
`property3` can't be blank (value: undefined).
This is what I have posted:
{
"id":0,
"property2":"foo",
"property3":"bar",
"property4":"R"
}
The weirdest part of this is that when I try to run this through the LoopBack API Explorer, it works just fine. I have the same issues with PATCH methods as well.
Any thoughts?
Thanks
I found the cause. In previous APIs I have worked with, the back-end was set up with a model binder that would apply the properties it needed and discard the ones it did not. So I have typically send the entire object in POSTs/PUTs/etc. In this case, we do not have that, so it was throwing this weird error. Once I added a method to my Angular auto-mapper that would strip the object down to only the bare necessities, it worked just fine.
In the end, I could have figured that out if the error message had been better.