For Drupal 8 (v8.3.7), you can use its RESTful Web Services module to add the REST export view. This way you will be able to have a REST API to get all pages and articles.

Suppose we have a page called AboutUs, we can get its content via the API:

<response>
    <item key="0">
        <status>Published</status>
        <body>
            <![CDATA[ <p>We are a non profit organisation.</p> ]]>
        </body>
    </item>
</response>

Now we install a module called Content Moderation, and apply its Editorial workflow to the Basic page content type. As a result, an editor can update the published page AboutUs as "We are a non profit organisation in Europe"., and save as draft (not published yet) while keeping its previous revision published.

Via the API, we still get the same response as before, i.e., "We are a non profit organisation."

My question is, is it possible to get the draft version via API somehow? In other words, instead of getting "We are a non profit organisation.", is it possible to get the following draft version:

<response>
    <item key="0">
        <status>Published</status>
        <body>
            <![CDATA[ <p>We are a non profit organisation in Europe.</p> ]]>
        </body>
    </item>
</response>

If it is possible, how (to configure REST export, or any other way)? Thank you.

Comments

murat_halici’s picture

Hi, I was just wondering if you were able to find a solution for this.  Thanks.

rjenkins’s picture

I found this while looking for a way to serve node revisions via the REST API. What I ended up doing was using Views Rest Export. I created a view showing Content Revisions, and checked the "Provide a REST Export" option. For my purposes I needed to be able to specify the node ID and revision ID to get the revision I wanted, so I added those as contextual filters. And that was it for me, it gave me the node revision as a JSON export. Hope that helps somebody.