Can't set post as featured with Admin API?

I’m trying to set a post as featured using the Admin API.

I’m receiving the following error:

error:  [{
"message"=>"Validation error, cannot save post.",
"context"=>"Validation failed for featured.",
"details"=>[{"keyword"=>"type", "dataPath"=>".posts[0].featured", "schemaPath"=>"#/properties/featured/type", "params"=>{"type"=>"boolean"}, "message"=>"should be boolean"}],

I’ve tried various formats of the featured value (true, 1, yes), but the error is the same. I tried ‘false’, too, just to check if this was a problem with setting a post to featured on creation.

All attempts resulted in the same error.

If I remove the featured field completely, the post is created without error.

Is setting a post as featured this not something you can do with the Admin API?


If you can do it from /ghost, you can do it through the api. Try opening dev tools in your browser and mark a post featured while watching the network tab? What’s the endpoint and payload?

Thanks, @Cathy_Sarisky, that helped me work out what the problem was.

To cut a [very] long story short, I was sending the payload in x-www-form-urlencoded format. The Ghost Admin API was interpreting this perfectly for everything except boolean values.

I switched to "Content-Type: application/json" and converted my payload to JSON and things started working.

Thanks all!


1 Like