Hello,
I am posting to local Ghost server by POST
ing to /posts
. I am expecting the post to be visible on the homepage, but I am unable to see the post on the homepage without a workaround.
How would I go about publishing a post via a single POST
request to /posts
?
Below are the expected, actual, and workaround scenarios.
Expected:
GIVEN a valid access token
—AND a user of role Author
WHEN POST
ing to /post
—AND request body
is
{
posts: [
{
title: "My API post " + Date.now(),
"mobiledoc": "{\"version\":\"0.3.1\",\"markups\":[],\"atoms\":[],\"cards\":[[\"card-markdown\",{\"cardName\":\"card-markdown\",\"markdown\":\"Some Text\"}]],\"sections\":[[10,0]]}",
status: "published",
author_id: "5adf9b67-e1d2-481f-a348-"
}
]
}
—AND Bearer token is set in the headers
THEN post is saved to db
—AND post status
is published
—AND post is visible on homepage
Actual:
GIVEN a valid access token
—AND a user of role Author
WHEN POST
ing to /posts
—AND request body
is
{
posts: [
{
title: "My API post " + Date.now(),
"mobiledoc": "{\"version\":\"0.3.1\",\"markups\":[],\"atoms\":[],\"cards\":[[\"card-markdown\",{\"cardName\":\"card-markdown\",\"markdown\":\"Some Text\"}]],\"sections\":[[10,0]]}",
status: "published",
author_id: "5adf9b67-e1d2-481f-a348-"
}
]
}
—AND Bearer token is set in the headers
THEN post is saved to db
—AND post status
is published
—AND post is not visible on homepage
I am able to workaround this problem by making a simple PUT
request to /posts/:id
right after the post has been created. I’d prefer not make this second request if possible.
Workaround
GIVEN a valid access token
—AND a user of role Author
WHEN POST
ing to /posts
—AND request body
is
{
posts: [
{
title: "My API post " + Date.now(),
"mobiledoc": "{\"version\":\"0.3.1\",\"markups\":[],\"atoms\":[],\"cards\":[[\"card-markdown\",{\"cardName\":\"card-markdown\",\"markdown\":\"Some Text\"}]],\"sections\":[[10,0]]}",
status: "published",
author_id: "5adf9b67-e1d2-481f-a348-"
}
]
}
—AND Bearer token is set in the headers
—AND PUT
ing to /posts/:id
with :id
created from previous request
—AND request body
is
{
posts: [
{
id: postId,
}
]
}
THEN post is saved to db
—AND post status
is published
—AND post is visible on homepage