Assistance Required with Invalid Key Error on User-Todo Relationship in Strapi

I hope this message finds you well.

I am encountering an issue while working with a Many-to-One relationship between the User and Todo collection types in my Strapi application. Specifically, I am trying to associate a Todo with a User when creating or updating the todo, but I keep receiving the following error:
{
“data”: null,
“error”: {
“status”: 400,
“name”: “ValidationError”,
“message”: “Invalid key user”,
“details”: {
“key”: “user”,
“source”: “body”
}
}
}
Here are the steps I have followed so far:

  1. I have created a Many-to-One relationship between Todos and Users in the Content-Type Builder.
  2. I have tested sending a POST request to create a new Todo and include the user field in the request body, with the user ID like this:
    {
    “data”: {
    “title”: “Learn Strapi”,
    “description”: “Understand relationships in Strapi”,
    “user”: 1
    }
    }
  3. Despite this, I am receiving the “Invalid key user” validation error.

Could you kindly help me troubleshoot this issue? I would appreciate guidance on:

  • Ensuring the correct relationship is configured.
  • Any potential permissions or configurations that might cause this error.
  • Any other steps I may have missed.

I make relation between todo and user → User has many todos

Hi there! I’m sorry to hear you’re having trouble with your Strapi application. Let’s see if we can figure this out together.

Ensuring the Correct Relationship is Configured

  1. Check the Content-Type Builder: Ensure that the relationship between User and Todo is correctly set up as a Many-to-One relationship in the Content-Type Builder. The User should be the target model, and Todo should have a field referencing User.
  2. Field Configuration: Make sure the field in the Todo content type is correctly configured to accept a relation to the User model. The field should be of type relation and should reference the User model.

Potential Permissions or Configurations

  1. Permissions: Verify that the necessary permissions are set up for the Todo content type. You need to ensure that the create and update permissions for the Todo content type include the user field.
  2. Role Permissions: Check the roles and permissions to ensure that the role you are using to create or update the Todo has the necessary permissions to access the User model.

Other Steps to Consider

  1. Field Permissions: Ensure that the user field in the Todo content type has the create and update permissions enabled.
  2. API Endpoint: Make sure you are using the correct API endpoint to create or update the Todo with the user field included in the request body.

Regards,
Alice R.
mychart Wellstar org