I want to use Admin API from @tryghost/admin-api to update the contents of a post.
As noted in AdminAPI: getting UPDATE_COLLISION · Issue #103 · TryGhost/SDK · GitHub the problem which I have is an API misuse. Can somebody explain how to use Admin API to update the contents of a post?
This was my attempt:
await api.posts.edit({"id": "5c8051da2a25b600c01ff9ee", "mobiledoc": JSON.stringify(md), "updated_at": "2019-05-09T11:39:37.000Z"})
Fails with:
{ UpdateCollisionError: Saving failed! Someone else is editing this post.
at makeRequest.catch (/tmp/node_modules/@tryghost/admin-api/lib/index.js:292:33)
at process._tickCallback (internal/process/next_tick.js:68:7)
name: ‘UpdateCollisionError’,
context: ‘Saving failed! Someone else is editing this post.’,
type: ‘UpdateCollisionError’,
details:
{ clientUpdatedAt: ‘2019-05-09T11:39:37.000Z’,
serverUpdatedAt: ‘2019-05-08T15:40:57.000Z’ },
property: null,
help: null,
code: ‘UPDATE_COLLISION’,
id: ‘36069d20-723f-11e9-9b05-d55f47be1c26’ }
Nobody else is editing that post in reality.