Feature Image through API gone

Hey guys,

I’ve tried to create several workflows through automation platforms such as Make and n8n and I found a way to post blogs posts and then update the feature image for the post (I thought they would be baked into the post then).

But it seems they are just being held on a temporary URL and then gone after a few hours.

I use something a kin to this followed by a PUT request:

const currentPost = $node[‘Fetch Current Post’].json.posts[0];
const newImageUrl = $(‘HTTP Request3’).first().json.output[0];

const updateData = {
posts: [{
id: currentPost.id,
updated_at: currentPost.updated_at,
title: currentPost.title,
slug: currentPost.slug,
mobiledoc: currentPost.mobiledoc,
feature_image: newImageUrl,
featured: true,
status: currentPost.status,
locale: currentPost.locale,
visibility: currentPost.visibility
}]
};

console.log(‘Update data being sent:’, JSON.stringify(updateData, null, 2));

return {
json: updateData
};

How can I make it update the post and put the image into the featured image functionality and have it host the image. It would save me a lot of headache.
The only option if not, is to host the images somewhere else and the nput in that URL - but that seems silly considering you can actually host images through the feature image input?

Anyone know?

Did you upload the feature image to Ghost?

There’s a file upload endpoint that you’ll want to upload your file to. Good discussion of how to interact with it at the end of this thread:

I’m not able to tell from your example code where exactly your file is going, if anywhere.

Aside: You don’t need to include everything in the PUT request, and you probably specifically do NOT want to include the mobiledoc (phased out). You should be able to include the id or slug, updated_at, and the feature_image only.

1 Like