Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

738
Views
strapi v4: How to create a Entry with Relation?

When I create a new entry in my Collection-Type all of the values for the fields get added to the newly created entry EXCEPT for the value for the field with the Relation type.

So for example in my event Collection-Type I have name, performers, venue, address, date, time, description and user

user is a Relation type (Relation with User (from:users-permission))

The rest are either Text, DateTime, RichText, etc.

after I get the data from the form I end up having a object similar to:

var values = {
        name: 'namevalue',
        performers: 'whatever',
        venue: 'whatever',
        address: 'xyz address',
        date: '2022-12-15',
        time: '10:00 PM',
        description: 'Description of the Event',
    }

I then just edit the values object above to get the final version of value as

var values = {
            name: 'namevalue',
            performers: 'whatever',
            venue: 'whatever',
            address: 'xyz address',
            date: '2022-12-15',
            time: '10:00 PM',
            description: 'Description of the Event',
            user:1
        }

PLEASE TAKE NOTE OF the user:1 added to the object above

However after submitting the above values to the correct endpoint:

const res = await fetch(`${API_URL}/api/events`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                Authorization: `Bearer ${token}`,
            },
            body: JSON.stringify({
                data: values,
            }),
        })

In the Strapi backend the user field and value totally does not show up.... For example this is what I get:

{
  data: {
    name: '13',
    performers: '13',
    venue: '13',
    address: '13',
    date: '2022-06-10',
    time: '8:00 PM',
    description: '13'
  },
  files: undefined
}

As you can see the rest of the data I get and it then gets added to the newly created Entry but WITHOUT the Relation value that I need and want.

What am I doing wrong and how to fix this????

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!