R
Railway8mo ago
SLUK 06

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
Percy
Percy8mo ago
Project ID: N/A
root
root8mo ago
Do you have a default value set for the area column in the buttons table in your database?
SLUK 06
SLUK 068mo ago
no default value was set in any column
root
root8mo ago
If you're trying to insert DEFAULT, you need to set default values.
SLUK 06
SLUK 068mo ago
I'm using an api to insert json data, and testing it through postman
root
root8mo ago
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.
SLUK 06
SLUK 068mo ago
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.