From version 2.3.0, you can retrieve content using friendly URLs. In addition to using the endpoint as in previous versions: http://localhost:8080/api/episerver/v2.0/content/6, a friendly name URL of a specific content item can be used for data query: http://localhost:8080/en/alloy-plan/. To use this friendly name URL to retrieve data, you only need to set Accept header to 'application/json' in your request.
The parameters for the request (for example, expand) should be the same as before.
The flow is illustrated by the image below.
The language to get content is extracted from the URL. If it is empty, then accept-language header is chosen.
Note: If the call to the Content Delivery API does not set the accept-language header (that is, the accept-language header is empty), as is the normal behavior of web browsers such as Chrome, they can automatically assign the value of the preferred language to accept-language (for example, en-US). The API will then use this value to query data.
Note the following restrictions:
CustomContentApiRouteService) that inherits
ContentApiRouteServiceand then, register a transient lifecycled implementation for a ContentApiRouteService in the initialization service.
ShouldRouteRequestto prevent the URL from being re-written in unexpected cases. For example, requests whose accept types contain application/json are currently handled by our partial router. So, you can add one more header (for example, Routed-By-ContentApi) for CD-related requests and then, use this header in the function to decide whether our partial router should handle the request and rewrite URL later on.
Last updated: Mar 11, 2019