I am new to admin API, and I want to post an article to ghost. I am using python.
first I prepare the token
GHOST_API_URL = “http://localhost:3480/ghost/api/admin/posts/?format=html”
ADMIN_API_KEY = “67…:13…”
id, secret = ADMIN_API_KEY.split(‘:’)
iat = int(date.now().timestamp())
header = {‘alg’: ‘HS256’, ‘typ’: ‘JWT’, ‘kid’: id}
payload = {
‘iat’: iat,
‘exp’: iat + 5 * 60,
‘aud’: ‘/admin/’
}
token = jwt.encode(payload, bytes.fromhex(secret), algorithm=‘HS256’, headers=header)
then I post the data
post_data = {
“posts”: [
{
“title”: “test1”,
“html”: “test1”,
}
]
}
headers = {
“Authorization”: f"Ghost {token}",
“Content-Type”: “application/json”,
}
response = requests.post(GHOST_API_URL, json=post_data, headers=headers)
The title is posted, but the html is not posted. Why? How can I post the html? Please help.
Thanks!