Post data via REST API without ID as relation but some another field

System Information
  • Strapi Version: v3.5.2
  • Operating System: Manjaro Linux 5.10.19-1-MANJARO
  • Database: MySQL (MariaDB)
  • Node Version: v14.16.0
  • NPM Version: 7.6.2
  • Yarn Version: 1.22.10

Hi. I would like to make a POST request via REST API and provide a relation. But in my case, I cannot provide the primary key of relation which is “id” generated by Strapi. I want to use as relation another field added by me which is “code” (type of string).

Should I make a custom endpoint in that case or it’s possible somehow?

I want to POST a request with data:

{
  "name": "nowosolski",
  "description": "",
  "code": "04",
  "voivodeship": { "code": "08" } // here should be ID
}

So instead of ID in “voivodeship”, I would like to use an additional field. Is it possible to do?

Or I should provide a new endpoint to search by “code” field then after I get it make another request with POST.

i have same issue. using id is bad because what if ids change then all data will be wrong

Same issue here :wave: :wave:
The only solution that i found possible was creating a method to convert in some way the field that you want to the id and send the id instead the field that you set…

It’s a little bit hard to explain