Admin API's api.posts.edit endpoint always times-out

Hi.
I’m trying to remove a tag from a group of posts and everything works fine until I need to update each post.
Ghost Admin API Documentation says:

  1. Tag and author relations will be replaced, not merged, and I’ve done so.
  2. Required fields: updated_at, and I’ve also done so.

However, whenever I try to do this:
await api.posts.edit({id: post.id, updated_at: post.updated_at, tags: post.tags})
I’m getting a timeout error.

For the API reference, I’m using https://github.com/TryGhost/api-demos with three or more years old examples so I’m not even sure that they work. Is there any other source for learning about Admin API?

Cheers.

That looks fine - I run very similar code in Phantom Admin, although I do it with a .then instead of an await.

Can you please console log the values of post.id, post.updated_at, and post.tags, to see if perhaps there’s a surprise in there somewhere?

Thank you @Cathy_Sarisky for your time and effort in helping me. I’m constantly using console.log in cases when I’m learning things, and the values are correct:

post.id: 640093dd8cb806003d19c9aa
post.updated_at: 2023-03-04T14:11:09.838Z
tags: [
  {
    id: '630f99718264ed003d6b8d1e',
    name: 'Svijet',
    slug: 'svijet',
    description: null,
    feature_image: null,
    visibility: 'public',
    og_image: null,
    og_title: null,
    og_description: null,
    twitter_image: null,
    twitter_title: null,
    twitter_description: null,
    meta_title: null,
    meta_description: null,
    codeinjection_head: null,
    codeinjection_foot: null,
    canonical_url: null,
    accent_color: null,
    created_at: '2022-08-31T17:25:05.000Z',
    updated_at: '2022-09-15T19:48:36.000Z',
    url: 'https://www.morski.hr/tag/svijet/'
  },
  {
    id: '62d9877c17c097004db34881',
    name: 'Japan',
    slug: 'japan',
    description: null,
    feature_image: null,
    visibility: 'public',
    og_image: null,
    og_title: null,
    og_description: null,
    twitter_image: null,
    twitter_title: null,
    twitter_description: null,
    meta_title: null,
    meta_description: null,
    codeinjection_head: null,
    codeinjection_foot: null,
    canonical_url: null,
    accent_color: null,
    created_at: '2022-07-21T17:06:04.000Z',
    updated_at: '2022-07-30T12:00:05.000Z',
    url: 'https://www.morski.hr/tag/japan/'
  },
  {
    id: '62d9877b17c097004db34868',
    name: 'Morske crtice',
    slug: 'morske-crtice',
    description: null,
    feature_image: null,
    visibility: 'public',
    og_image: null,
    og_title: null,
    og_description: null,
    twitter_image: null,
    twitter_title: null,
    twitter_description: null,
    meta_title: null,
    meta_description: null,
    codeinjection_head: null,
    codeinjection_foot: null,
    canonical_url: null,
    accent_color: null,
    created_at: '2022-07-21T17:06:03.000Z',
    updated_at: '2022-09-09T09:19:23.000Z',
    url: 'https://www.morski.hr/tag/morske-crtice/'
  }
]

Any message on the Ghost logs themselves? (Assuming you have access - they’re in content/logs probably.)

And one other thought - is there a firewall rule that might specifically be blocking a PUT request?

It’s a Ghost(Pro) so no joy there.

Regarding the firewall, I can make content using the Postman and POST request at /admin/posts/

I’ve succeeded in creating my Fathom-to-Ghost solution for popular posts, well all but one thing, and that’s the sorting on the webpage, starting with the most viewed one.
@Cathy_Sarisky you mentioned that you’re running a similar script, would it be possible to know how you’d managed to sort your most popular posts? I was hoping to be able to use the “updated_at” timestamp since I’m updating my posts in a specific order, but it seems that that field doesn’t change with API PUT updates, which I find very unusual.

Thank you again for your time and effort.

Cheers.

Sounds like you need to update your put request to include a new updated_at value? :)

Doesn’t work, Ghost expects the same “update_at” as it was in the original post. It even throws an error if there’s a difference. Thank you though for the reply.