i’m trying to create a page from my ghost site, I have the customized template that interacts with my node.js server and I got the create post api to work but I’m not sure what endpoint to call if I want to create a page and populate. Not much in the documentation.
my function returns a 400 bad request
const createPage = async (aiResponse) => {
const resp = aiResponse.message.content;
const url = "https://site-url/ghost/api/admin/pages"
const headers = { Authorization: `Ghost ${token}`, ContentType:'multipart/form-data' };
const payload = {
title: 'Answer Page',
html: `<p>${resp}</p>`,
mobiledoc: JSON.stringify(converter.toMobiledoc(`<p>${resp}</p>`)),
status: 'published' // or 'draft' if you want to manually publish it later
};
return axios.post(url, payload, { headers })
.then(response => response.data)
.catch(error => console.error(error));
};