Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

501
Visualizações
Strapi How to link relations between collections REST API

Strapi v4, postgres.

I have two collections Sprites and Tags and I want to link those collections throught REST API when I creating a new Sprite entry. I have a simple API endpoint which is firing strapi.controller('api::sprite.sprite').create(), but I cant understand how can I specify relation to Tags. I tried many various variants but nothing not worked for me.

For example:

{
    "data": {
    "tags": [1, 2],
    }
}

As I understand right I need to specify Tag's ID, as said at documentation but its not worked for me. If I create a new entry from Content Manager and specify relation manually its works good.

Also I tried to open all permissions to Tag collection

Sprites:

{
  "kind": "collectionType",
  "collectionName": "sprites",
  "info": {
    "singularName": "sprite",
    "pluralName": "sprites",
    "displayName": "Sprite",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    ...
    "tags": {
      "type": "relation",
      "relation": "manyToMany",
      "target": "api::tag.tag",
      "inversedBy": "sprites"
    }
  }
}

And Tags:

{
  "kind": "collectionType",
  "collectionName": "tags",
  "info": {
    "singularName": "tag",
    "pluralName": "tags",
    "displayName": "tag"
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "name": {
      "type": "string"
    },
    "sprites": {
      "type": "relation",
      "relation": "manyToMany",
      "target": "api::sprite.sprite",
      "inversedBy": "tags"
    }
  }
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda