Can't import relations in strapi, server error 500

System Information
  • Strapi Version: [v3.6.8]
  • Operating System: windows 10
  • Database: postregs
  • Node Version: v.14.15.1
  • NPM Version: 6.14.8
  • Yarn Version:

Hi, I tried to import a json file like this,

}
    name1: "andrea",
    name2: null,
    indirizzo: "VIA gallo, 30",
    citta: "MILANO'",
    provincia: "FC",
    nazione: "IT",
    cap: 47000,
    addresses: [
      {
        via: " via zero ",
        provincia: "mn",
        nome: "mauro",
        cap: 77899,
        locali: "LOCALI",
      },
      {
        via: " via quattro",
        provincia: "mn",
        nome: "paolo",
        cap: 77899,
        locali: "entity.DDLOCALI",
      },
]
}

using this code

module.exports = () => {
  strapi.services.client.create({
   name1: "andrea",
    name2: null,
    indirizzo: "VIA gallo, 30",
    citta: "MILANO'",
    provincia: "FC",
    nazione: "IT",
    cap: 47000,
    addresses: [
      {
        via: " via zero ",
        provincia: "mn",
        nome: "mauro",
        cap: 77899,
        locali: "LOCALI",
      },
      {
        via: " via quattro",
        provincia: "mn",
        nome: "paolo",
        cap: 77899,
        locali: "entity.DDLOCALI",
      },
]}

Strapi imports only client but not the address relation, if i try using the api, using post method i recive this error

{
    "statusCode": 500,
    "error": "Internal Server Error",
    "message": "An internal server error occurred"
}

don’t know how to solve this issue

settings.json files

"kind": "collectionType",
  "collectionName": "addresses",
  "info": {
    "name": "address"
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "nome": {
      "type": "string",
      "required": true
    },
    "via": {
      "type": "string",
      "required": true
    },
    "cap": {
      "type": "biginteger",
      "required": true
    },
    "locali": {
      "type": "string",
      "required": true
    },
    "provincia": {
      "type": "string",
      "required": true
    }
  }
}

{
  "kind": "collectionType",
  "collectionName": "clients",
  "info": {
    "name": "client",
    "description": ""
  },
  "options": {
    "increments": true,
    "timestamps": true,
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "nome1": {
      "type": "string"
    },
    "nome2": {
      "type": "string"
    },
    "codice_venditore": {
      "type": "biginteger",
      "unique": false
    },
    "indirizzo": {
      "type": "string",
      "required": true
    },
    "citta": {
      "type": "string",
      "required": true
    },
    "provincia": {
      "type": "string",
      "required": true
    },
    "cap": {
      "type": "biginteger",
      "required": true
    },
    "addresses": {
      "collection": "address"
    },
    "nazione": {
      "type": "enumeration",
      "enum": [
        "IT",
        "FR",
        "ES",
        "GE"
      ],
      "required": true,
      "default": "IT"
    }
  }
}


solved, strapy don’t currently support nested relational creation, look here Creating new items for a collection(having relations) through STRAPI default API is not working