Skip to content

Invalid API version #594

@jannepeltola

Description

@jannepeltola

When I try to run gctools delete-posts <site url>/ghost/api <admin token> --tag "<tag>", I get the following output:

✔ Initialising API connection
   →  Initialised API connection for <site url>/ghost/api
✖ Fetch Content from Ghost API
  Deleting posts from Ghost
error Done with errors [
  Error [RequestNotAcceptableError]: Request could not be served, the endpoint was not found.
      at /Users/janne/git/gctools/node_modules/@tryghost/admin-api/lib/admin-api.js:463:33
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async discover (file:///Users/janne/git/gctools/lib/batch-ghost-discover.js:102:20)
      at async _Task.task [as taskFn] (file:///Users/janne/git/gctools/tasks/delete-posts.js:58:33)
      at async _Task.run (file:///Users/janne/git/gctools/node_modules/listr2/dist/index.js:1965:11) {
    context: 'Provided client accept-version v5.0 is behind current Ghost version v5.120.',
    type: 'RequestNotAcceptableError',
    details: null,
    property: null,
    help: 'Try upgrading your Ghost API client.',
    code: 'UPDATE_CLIENT',
    id: '41680530-37c0-11f0-b2b1-a9647e7f1507',
    ghostErrorCode: null
  }
]
ok Successfully deleted 0 posts in 138ms.

When I edit tasks/delete-posts.js to use "5.12.0" as the Accepted-Version, I get this:

✔ Initialising API connection
   →  Initialised API connection for <site url>/ghost/api/admin
✖ Fetch Content from Ghost API
  Deleting posts from Ghost
error Done with errors [
  Error [NotFoundError]: Resource not found
      at /Users/janne/git/gctools/node_modules/@tryghost/admin-api/lib/admin-api.js:463:33
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
      at async discover (file:///Users/janne/git/gctools/lib/batch-ghost-discover.js:102:20)
      at async _Task.task [as taskFn] (file:///Users/janne/git/gctools/tasks/delete-posts.js:58:33)
      at async _Task.run (file:///Users/janne/git/gctools/node_modules/listr2/dist/index.js:1965:11) {
    context: null,
    type: 'NotFoundError',
    details: null,
    property: null,
    help: null,
    code: null,
    id: '17e88f00-37c4-11f0-b2b1-a9647e7f1507',
    ghostErrorCode: null
  }
]
ok Successfully deleted 0 posts in 129ms.

It seems like the tool sends an Accepted-Version header that's not accepted by the API but also fails when the proper version is sent.

What should I do?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions