sqlMessage: "Field 'area' doesn't have a default value"
I need help to resolve this error:
code: 'ER_NO_DEFAULT_FOR_FIELD',
error: 1364,
sqlState: 'HY000',
sqlMessage: "Field 'area' doesn't have a default value",
sql: 'insert into
buttons
(area
, link
, loc
, name
, up
) values (DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT)';
Using the get method works, but using the post method this error occurs.7 Replies
Project ID:
N/A
Do you have a default value set for the
area
column in the buttons
table in your database?no default value was set in any column
If you're trying to insert DEFAULT, you need to set default values.
I'm using an api to insert json data, and testing it through postman
I'm 99% sure that this is unrelated to Railway - you'd have better luck asking in the forum of one of the libraries you're using for this, or in a general programming forum.
I was taking a better look and it seems that the data is not being sent correctly, so the database is looking for a default value, as soon as I solve it I will send the solution, to help other people who may have the same problem
I was making the request using JSON in this format:
[
{
"up": "test",
"area": "test",
"loc": "test",
"name": "test",
"link": "test"
}
]
I just removed the brackets "[ ]", and it worked.