- What’s your URL? https://grantwinney.com
- What version of Ghost are you using? 2.19.0
- What configuration? self-hosted
- What browser? Brave 0.61.52 Chromium: 73.0.3683.86 (Official Build) (64-bit)
- What errors or information do you see in the console? n/a
- What steps could someone else take to reproduce the issue you’re having? details below
I used the Admin API to create a new post, in which all I specified was the title, and it was created fine.
Then I added 5 minutes to the updated_at
field and turned around and tried to “update” it at the /admin/posts/{id}/
endpoint. The comment_id
was set to “5c9cca4414afbe0805d2b517” and the uuid
set to “bd68ac57-0854-4d3d-bd3f-5ac6293c7177”.
The update fails with the following, and I’m not sure why it seems to think uuid
and comment_id
are additional properties that should not be in the payload.
{
"errors": [{
"message": "Validation error, cannot edit post.",
"context": "Validation failed for 'posts[0]'",
"type": "ValidationError",
"details": [{
"keyword": "additionalProperties",
"dataPath": ".posts[0]",
"schemaPath": "#/additionalProperties",
"params": {
"additionalProperty": "uuid"
},
"message": "should NOT have additional properties"
}, {
"keyword": "additionalProperties",
"dataPath": ".posts[0]",
"schemaPath": "#/additionalProperties",
"params": {
"additionalProperty": "comment_id"
},
"message": "should NOT have additional properties"
}],
"property": "posts[0]",
"help": null,
"code": null,
"id": "1ba48e70-5155-11e9-be0e-1702dc9d57c3"
}]
}
Maybe those fields are not considered “writable” so they’re not allowed to be sent? Which fields are considered writable? It’d be nice if they were ignored as long as they hadn’t changed…
All writable fields of a post can be updated via the edit endpoint.
From this statement in the docs, I was assuming I could do a GET and immediately turn around and PUT it (after updating the updated_at
timestamp):
The
updated_at
field is required as it is used to handle collision detection, and ensure you’re not overwriting more recent updates. It is recommended to perform a GET request to fetch the latest data before updating a post.