Plaintext value is empty using the API

When I make an API request and limit the return fields with fields, the plaintext value is empty.


It does return the value if I removed the fields parameters.


Ghost Version 3.1.0

Is there anything I’m missing?


Any thoughts about this?

Just did a quick check for this and it all worked as expected for v3 Content API (note you have v2 on both of your screenshots)
Was verifying the output with the following test (added it to this suite):

    it('posts with plaintext field', function () {
        return request
            .set('Origin', testUtils.API.getURL())
            .expect('Content-Type', /json/)
            .expect('Cache-Control', testUtils.cacheRules.private)
            .then((res) => {
                localUtils.API.checkResponse(res.body.posts[0], 'post', null, null, ['id', 'title', 'plaintext']);

I tried this on the latest master.

Anything specific about the html content in posts missing the plaintext? Can’t really think of why this would not work :slight_smile:

Yes, tried it with the v3 and it is not working too.

Also, if I removed formats=plaintext and only provides the fields, plaintext and html are also empty.


If I want to return only the id and html for example, the html is empty.


It’s pretty hard to pinpoint the issue here :thinking: Could you try doing similar request on a new instance and if it does’t happen they try to import some of the data from your current instance?
My current thinking is:

  1. It might be something with the data
  2. There were some modifications in the code itself (did you do anything custom?
  3. Maybe something database specific? Which version are you running? Is it MySQL or SQLite?

Would be helpful if you could provide more information about the environment the instance is running in. Also try running the request using plain curl, so we can eliminate browser extension doing something strange.

I’m trying on a local Mac development setup.

I also created a Ghost Pro instance to try on it ( So, with the default content, there is no issue and everything is working fine, but when I deleted the instance content from Delete all content and then imported my content file, the issue happens.,title,plaintext&formats=plaintext

With the imported content, I tried this time to delete all the posts one by one to see that it might be a content issue, but still the issue still happens. After deleting all posts, I created a new post to check but still got plaintext empty.

To make things working again, I deleted my content from Delete all content and then imported the original Ghost Pro one and it worked again.

The content file:

I’m thinking maybe some data fields are inserted to the database from my own file which could make the issue other than about the content of the posts.

@ahmadajmi the export file you provided seems to be broken :confused: looks like the same content has been duplicated twice :wink:

On the note. I have tested this scenario with your data and then with some of my own. Was able to reproduce this issue when requesting posts with fields=id,title,plaintext through Content API while having “members” enabled. Will try and investigate it quickly and will post here if I find a fix for it.

Have started a PR wit a possible fix here -

As a quick workaround for this issue add visibility to your fields query parameter like so fields=id,title,plaintext,visibility

You are right, it looks like plaintext is only empty when we have “members” enabled.

Adding visibility fixed it. I tried it with the following example and plaintext is now visible. Awesome!,title,url,created_at,feature_image,visibility&formats=plaintext

Thanks a lot!