Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

CMS 12 + Content Delivery API 3 (Prerelease)

Vote:
 

Hi!

I'm having some trouble with the new Content Delivery API for CMS 12. At the moment I'm working with 3.0.0-ci-002490.

Everything works fine using the endpoints from /api/episerver/v3.0/ but the content delivery API does not kick in when using "friendly URLs" (e.g. /en) with the Accept: application/json header, which if course works fine in the CMS 11 + Content Delivery API 2.x.

I feel I must have missed something in the setup. Is there a middleware that needs to be plugged in? I currently have:

            services.AddContentDeliveryApi(null, options =>
            {
                options.SetSiteDefinitionApiEnabled(true);
                options.SetMinimumRoles(string.Empty);
            });

in the ConfigureServices method, and nothing related to the content delivery API in Configure as far as I can see:

            app.UseStaticFiles();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapContent();
            });

Has anyone gotten this to work and can provide some insight? Would be much appreciated :-)

Best regards
/Anders

#265480
Edited, Oct 22, 2021 7:55
Vote:
 

Hi,

There's no middleware, but an endpoint routing matcher policy. You enable it with:

services
    .AddContentDeliveryApi()
    .WithFriendlyUrl();
#265536
Edited, Oct 23, 2021 13:09
Vote:
 

Hey Johan, thanks!

I couldn't find the .WithFriendlyUrl() extension but .AddContentApiRouting() did the trick for me (found in namespace EPiServer.ContentApi.Routing).

Best regards
/Anders

#265614
Oct 25, 2021 13:38
Vote:
 

Ah, in the release version the method is .WithFriendlyUrl(). So keep that in mind :)

#265615
Oct 25, 2021 13:39
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.