REST API POST field relation error must be defined

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I have a problem about use REST API POST. I set data sent to API POST but field relation error “ValidationError user must be defined.”

Js file

schema file

thanks for the help :grinning: :grinning: :grinning:

i solved the problem by create custom controller and using core action with query

  const user = await strapi.db
          where: { id: userId },

      if (!user) {
        throw new ValidationError("userId title must be defined.");

      const result = await super.create(ctx);

      if (!!result && result?.data) {
        await strapi.db.query("api::leave-detail.leave-detail").update({
          where: { id: },
          data: { user: userId },