Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • James Bondin 1 post 71 karma points
    Oct 07, 2024 @ 11:24
    James Bondin
    0

    How to include unpublished nodes whilst using Rest APIs

    Hi All

    Is there a a way to retrieve unpublished nodes using the following REST API? /umbraco/rest/v1/content/search

    i know we need to use the InternalIndex to get unpublished nodes....but how do we do that using the API?

    Thanks in advance for any help

  • Garðar Þorsteinsson 118 posts 564 karma points
    Oct 07, 2024 @ 15:41
    Garðar Þorsteinsson
    0

    Hi James,

    Take a look at the documentation regarding the Preview functionality under Concepts.

    https://docs.umbraco.com/umbraco-cms/reference/content-delivery-api

    Similar to the preview concept in Umbraco, the Delivery API allows for requesting unpublished content through its endpoints. This is done by setting a Preview header to true in the API request. Accessing unpublished versions of your content nodes requires authorization via an API key configured in appsettings.json file using the Umbraco:CMS:DeliveryApi:ApiKey configuration key. To obtain preview data, you must add the Api-Key request header containing the configured API key to the appropriate endpoints.

    GET /umbraco/delivery/api/v2/content/item/11fb598b-5c51-4d1a-8f2e-0c7594361d15
    Preview: true
    Api-Key: my-api-key
    

    Is the API key not applied using the Api-Key request header, the unpublished content will not be included in the JSON response.

Please Sign in or register to post replies

Write your reply to:

Draft