Open NoWhereMan1979 opened 6 months ago
Hi dear Leo. I have problem with enum in DTO_FIELD in createUser api execution. If i remove the role from request, it works. couldn't figure it out why. Also my db encoding is UTF8 Thanks in advance.
Request body:
{ "username": "string2", "email": "string2", "password": "string2", "role": "ROLE_GUEST" }
Response:
{ "status": "ERROR", "code": 500, "message": "ERROR: invalid byte sequence for encoding \"UTF8\": 0xdd 0xdd\nCONTEXT: unnamed portal parameter $4\n" }
And this is my DTO:
#include OATPP_CODEGEN_BEGIN(DTO) ENUM(Role, v_int32, VALUE(GUEST, 0, "ROLE_GUEST"), VALUE(ADMIN, 1, "ROLE_ADMIN") ) class UserDto : public oatpp::DTO { DTO_INIT(UserDto, DTO) DTO_FIELD(String, id); DTO_FIELD(String, userName, "username"); DTO_FIELD(String, email, "email"); DTO_FIELD(String, password, "password"); DTO_FIELD(Enum<Role>::AsString, role, "role"); }; #include OATPP_CODEGEN_END(DTO)
UserDb:
QUERY(createUser, "INSERT INTO AppUser" "(id, username, email, password, role) VALUES " "(uuid_generate_v4(), :user.username, :user.email, :user.password, :user.role)" "RETURNING *;", PREPARE(true), // user prepared statement! PARAM(oatpp::Object<UserDto>, user))
Hi dear Leo. I have problem with enum in DTO_FIELD in createUser api execution. If i remove the role from request, it works. couldn't figure it out why. Also my db encoding is UTF8 Thanks in advance.
Request body:
Response:
And this is my DTO:
UserDb: