TypeError: expected string but received array postman TypeError: expected string but received array postman mongoose mongoose

TypeError: expected string but received array postman


TypeError: Expected string but received Array. ---throws an error in postman as well as in a terminal window. I suspect it could be the user schema definition mismatch

Please check your user model user schema egname: { type: String,required: true }it's receiving something else than expected.


try in your "body" tab, selecting "raw", and then to the right, select "JSON (application/json)" instead of "text".

I'm assuming your API endpoint uses JSON instead of a url-encoded form data, just because you are running an API using express and mongoose. but you should clarify that on the question if it isn't the case.

Write a proper JSON body, I mean, use double quotes for keys as in:

{"model": { "property": "value",  "property2": 1}}

and try with the wrapping object {"model": <YOUR BODY HERE>} or without to see what works for you, as it's typical to wrap the object, but sometimes people don't use them. (seeing this in your code: req.body.participant makes me think you probably don't).

(PS: not related with the question, but personally prefer ARC or Insomnia for rest clients, as the interface for them is cleaner)


If you want data to be sent in participants array all the fields should be participants and not participant

try sending data through raw data and then selecting application/data for better formatting