Relation is empty on POST

System Information
  • latest:
  • windows:
  • default:
  • latest:
  • latest:
  • Yarn Version:

I cannot populate my relation field. I have given it a good go to try to get it to work and have read most of the q&a on the forum and the documentation. To highlight the issue. I have two tables:
question: with a text field q and a relation: answer that has a 1 to 1 relationship to the table answer.
answer: has a text field called a

To keep it simple I am using POSTman with the following:
http://localhost:1337/api/questions

each variation does not populate the relation field
{"data":{
        "q": "this answer is b",
        "answers": "b"
}}

{"data":{
        "q": "this answer is b",
        "answers": {"a":"b"}
}}

{"data":{
        "q": "this answer is b",
        "answers": [{"a":"b"}]
}}

{"data":{
        "q": "this answer is b",
        "a": "b"
}}

I have given it a lot of time to try to get this to work, but I have to ask for help on this sorry.

A friend had pointed out I need to update the id field, not the ‘display’ field.

{"data":{
        "q": "this answer is a",
        "answers": 1
}}

I have a row in the answer table with id = 1 and a = “a”
But the relation field remains empty.

I got it to work. I needed to include the populate in the POST

http://localhost:1337/api/questions?populate=*
{"data":{
        "q": "this answer is c",
        "answer": 1
}}

Dude, I’m from Brazil, I created an account just to thank you, you deserve all the best in your life. Abraços, TE AMO