Admin API add a new post

Hi, im trying to use the ghost API to add a post on the website…

const GHOST_API = new GhostAdminAPI({
    url: END_POINT,
    version: "v3",
    key: GHOST_KEY
});

GHOST_API.posts.add({
    title: 'My first draft API post',
    mobiledoc: '{\"version\":\"0.3.1\",\"atoms\":[],\"cards\":[],\"markups\":[],\"sections\":[[1,\"p\",[[0,[],0,\"My post content. Work in progress...\"]]]]}'
}).then(result => {
    res.send(JSON.stringify(result) + " - SUCCESS!")
}).catch(err => {
    res.send(JSON.stringify(err) + " -  ERROR!")
});

The result being the Array of posts i already have, but it does not add the new one.

Ive used this guide: https://ghost.org/docs/api/v3/javascript/admin/

Hello,
There is a little update: i’ve tried post and pages, without success, i tried different ways of postring from api wich are: html, mobiledoc, using full tags, using full users (primary_user) nothing works… All i receive back is the already existing list of posts/pages.

Anyone have any idea? Maybe someone who correctly posted from API?

All i receive back is the already existing list of posts/pages.

If you’re getting that response back then it sounds like something is causing your code to not hit the right API endpoint, you’ve somehow managed to have a GET response cached as your POST response, or your own service’s response has been cached.

I’d try using console.log(result) and following your service’s logs to make sure it’s actually being called (if it’s not then your client is returning a cached result) and to see what the real response from Ghost’s API is.

It would help if you posted a bit more about the environment in which you’re trying to use the API.

Hi Kevin, thanks for the answer.
The environment is a simple Express app, actually the template version from the IntelliJ Webstorm IDE.
I have a test route eg: router.post('/test'), function (req,res) {//...});
There i wanted to test those APIs…

So far what i saw is that the makeApiRequest function is called into the library index.js and those params are all correct: endpoint is correct, method is POST, body seems correct actually is a Array of posts containing 1 post and so on…
I cannot really understand where i do wrong on this…

Thanks