I am running v0.3.25
I installed this through digitalocean droplet.
I’m currently having issues with the API where I’m able to fetch my posts but even when trying to create posts following the documentation, I am receiving fetched posts and status 200.
I’m doing most of my work in python so not sure if that is messing things up or if its a bigger issue
import requests
import json
import jwt
from datetime import datetime as date
# Admin API key goes here
key = 'my:key'
# Split the key into ID and SECRET
id, secret = key.split(':')
# Prepare header and payload
iat = int(date.now().timestamp())
header = {'alg': 'HS256', 'typ': 'JWT', 'kid': id}
payload = {
'iat': iat,
'exp': iat + 5 * 60,
'aud': '/v3/admin/'
}
# Create the token (including decoding secret)
token = jwt.encode(payload, bytes.fromhex(secret), algorithm='HS256', headers=header)
# Make an authenticated request to create a post
headers = {'Authorization': 'Ghost {}'.format(token.decode()),
'Content-Type': 'application/json',
'Accept': 'application/json'
}
data = {
"posts": [{
"title": "My test post",
"html": "<p>My post content. Work in progress...</p>",
"status": "published"
}]
}
url = 'http://mysite.com/ghost/api/v3/admin/posts/?source=html'
response = requests.post(url, json=data, headers=headers)
response.json()
And the result is just a list of published/draft posts but not the new post.
Anyone having a similar issue or thoughts on how to fix? I’ve also tried v2 but doesn’t seem to help