storyblok / wordpress-importer

A simple script for migrating content from WordPress to Storyblok.
MIT License
17 stars 12 forks source link

Error: Request failed with status code 404 #14

Closed emaia closed 2 years ago

emaia commented 2 years ago

Hi! I'm trying to import 342 posts from WP to SB but I get this error when I run the script. I can't find any media or relation to this media 3386 in my WP database. Any ideas?

❯ npm run migrate

> wp2storyblok@1.0.0 migrate
> node ./migrate-wp-to-storyblok.js

Fetched all the entries of posts type
/home/****/wordpress-importer/node_modules/axios/lib/core/createError.js:16
  var error = new Error(message);
              ^

Error: Request failed with status code 404
    at createError (/home/****/wordpress-importer/node_modules/axios/lib/core/createError.js:16:15)
    at settle (/home/****/wordpress-importer/node_modules/axios/lib/core/settle.js:17:12)
    at IncomingMessage.handleStreamEnd /home/****/wordpress-importer/node_modules/axios/lib/adapters/http.js:260:11)
    at IncomingMessage.emit (node:events:539:35)
    at endReadableNT (node:internal/streams/readable:1345:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  config: {
    url: 'https://blog.******/wp-json/wp/v2/media/3386',
    method: 'get',
    headers: {
      Accept: 'application/json, text/plain, */*',
      'User-Agent': 'axios/0.21.1'
    },
    transformRequest: [ [Function: transformRequest] ],
...
...
...
[Symbol(kCapture)]: false,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype] {
        accept: [ 'Accept', 'application/json, text/plain, */*' ],
        'user-agent': [ 'User-Agent', 'axios/0.21.1' ],
        host: [ 'Host', 'blog.****' ]
      }
    },
    data: {
      code: 'rest_post_invalid_id',
      message: 'ID inválido de post.',
      data: { status: 404 }
    }
  },
  isAxiosError: true,
  toJSON: [Function: toJSON]

My setup file contains:

content_types: [
    {
      name: 'posts',
      new_content_type: 'post',
      folder: 'blog',
      schema_mapping: {
        title: 'title',
        '_links.wp:featuredmedia.0': 'featured_image',
        content: 'content'
      }
    }
  ]
emaia commented 2 years ago

Reinstall WordPress fixed the problem. Sorry.