Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Can't Export #48

Open
baermathias opened this issue Oct 18, 2021 · 3 comments
Open

Can't Export #48

baermathias opened this issue Oct 18, 2021 · 3 comments

Comments

@baermathias
Copy link

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
@mfozmen
Copy link

mfozmen commented Nov 11, 2021

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

@wvanooijen92
Copy link

wvanooijen92 commented Nov 14, 2021

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 #20

For more info on customising plugins, read

@mfozmen
Copy link

mfozmen commented Nov 18, 2021

Thanks it works!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants