strapi-plugin-import-export-content icon indicating copy to clipboard operation
strapi-plugin-import-export-content copied to clipboard

Can't Export

Open baermathias opened this issue 4 years ago • 3 comments

When I try to export data, I get the following error:

error: "Not Acceptable"
message: "could not parse: TypeError: Cannot destructure property 'attributes' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined."
statusCode: 406

baermathias avatar Oct 18 '21 19:10 baermathias

same problem. any workaround?

strapi_1 | TypeError: Cannot destructure property 'attributes' of '(intermediate value)(intermediate value)(intermediate value)' as it is undefined. strapi_1 | at /srv/app/node_modules/strapi-plugin-import-export-content/services/exporter/exportUtils.js:91:17 strapi_1 | at Array.forEach (<anonymous>) strapi_1 | at cleanFields (/srv/app/node_modules/strapi-plugin-import-export-content/services/exporter/exportUtils.js:79:27) strapi_1 | at /srv/app/node_modules/strapi-plugin-import-export-content/services/exporter/index.js:21:27 strapi_1 | at Array.map (<anonymous>) strapi_1 | at getData (/srv/app/node_modules/strapi-plugin-import-export-content/services/exporter/index.js:21:13) strapi_1 | at async Object.exportItems (/srv/app/node_modules/strapi-plugin-import-export-content/services/import-export-content.js:55:25) strapi_1 | at async Object.exportItems (/srv/app/node_modules/strapi-plugin-import-export-content/controllers/import-export-content.js:93:20) strapi_1 | at async /srv/app/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:79:22 strapi_1 | at async /srv/app/node_modules/strapi-utils/lib/policy.js:68:5 strapi_1 | at async /srv/app/node_modules/strapi/lib/middlewares/parser/index.js:48:23 strapi_1 | at async /srv/app/node_modules/strapi/lib/middlewares/xss/index.js:26:9

mfozmen avatar Nov 11 '21 14:11 mfozmen

I think you are trying to export data from a plugin model (could also be a relation), that was the problem for me at least

You'll have to customise the plugin. I copied over the services and constants folder from node_modules/strapi-plugin-import-export-content to extensions/import-export-content

Then in extensions/import-export-content/services/exporter/exportUtils.js change the cleanFields function.

For me this worked:

// ... line 81
      const { type, model, collection, plugin } = attributes[itemKey];
// ...

// ... line 92

        // By default the plugin does not support models that come from plugins. 
        // It only looks through regular models. 
        // To make sure that plugin models are evaluated as well,
        // we determine where the source of the models is.
        const modelSource = plugin ? strapi.plugins[plugin].models : strapi.models;

        const { attributes } = model
          ? modelSource[model]
          : modelSource[collection];

this thread may also be useful https://github.com/EdisonPeM/strapi-plugin-import-export-content/issues/20

For more info on customising plugins, read

wvanooijen92 avatar Nov 14 '21 12:11 wvanooijen92

Thanks it works!

mfozmen avatar Nov 18 '21 08:11 mfozmen