Good morning,
I am new to ghost and I created my site on the ghost servers in order to test post publication via the API.
I want to upload an image from an url and then put it in an HTML post.
I think I have implemented the API correctly but it gives me an error: “Please select an image.”.
Here is the Code:
const [id, secret] = API_KEY. split(':');
const token = jwt.sign({}, Buffer.from(secret, 'hex'), {
keyid: id,
algorithm: 'HS256',
expiresIn: '5m',
audience: `/admin/`
});
const url = 'https://sportews-2.ghost.io/ghost/api/admin/images/upload';
const payload = {
images: [
{
url: "https://media.api-sports.io/football/teams/182.png",
ref: "6.png"
}
]
};
const headers = { Authorization: `Ghost ${token}`};
axios.post(url, payload, { headers })
.then(response => console.log(response))
.catch(error => {
console.error(error)
});