Import data from JSON

I want to import a json file into a collection.
I followed this video and updated for strapi 4. (now bootstrap is inside index.js)

Here is my code to simple create entries based on the json. When I console.log I can see my object correctly and typeof the element is object as well.

But I’m getting this validation error:

ValidationError: Invalid payload submitted for the creation of an entity of type Synergy. Expected an object, but got undefined
at Object.validateEntityCreation

How can I set up one time data import from json file for migration of a system? We already have an MVP that we can’t to transfer the data.

System Information
  • Strapi Version: 4.0.7
  • Operating System: Ubuntu
  • Database: sqlite
  • Node Version: 16.13
  • NPM Version: 8.5.2
  • Yarn Version:

Hello @sedatio
I am not sure if you are still looking for a solution, but I am posting it here for any other users who might be looking for a solution to a similar import issue.
In the project RC4Community, we are doing something similar, importing the JSON data from the cms/config/initialData and then writing it into the Strapi Collections.

The part of the code which creates the collections is here,

And the updated Stapiv4 Bootstrap link below, where the starting lines of code sets the Public Role for find, and findOne routes of API.

Please feel free to ask anything by tagging me @Dnouv
Thank you!

1 Like