Copied to clipboard

Flag this post as spam?

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


  • Craig100 1136 posts 2523 karma points c-trib
    Mar 30, 2021 @ 14:19
    Craig100
    0

    Culture specific content from webApi call

    Umb 8.12.2

    Hi,

    I have a headless install with two languages. If I call an API endpoint, which extends UmbracoApiController, I only get back content in the default language. What's the best practice to get either all language variants or a specified language variant back?

    Thnx

  • Stuart Mullinger 79 posts 422 karma points
    Mar 31, 2021 @ 11:10
    Stuart Mullinger
    0

    Hi Craig,

    Just looking into the same thing myself. Many of the Umbraco functions have a culture parameter. e.g.

        var title = node.Value("title", "it");
        var italianChildren = node.DescendantsOfType("blogEntry", "it");
    

    So, you need to update your controller to use this parameter. The culture is the ISO code (lower case), you can see that in Languages (under Settings).

    Stuart.

  • David Peck 690 posts 1896 karma points c-trib
    Mar 31, 2021 @ 11:12
    David Peck
    0

    I suggest you supply the locale in a header, or just in the path, and then set Thread.CurrentUICulture to the locale in question.

  • Craig100 1136 posts 2523 karma points c-trib
    Mar 31, 2021 @ 11:16
    Craig100
    1

    The answer is here:- https://our.umbraco.com/documentation/Reference/Language-Variation/

    Link provided by Jesper on the Umbraco Slack channel.

    So I can do things like https://mydomain.com/umbraco/api/getMyThings?culture=fr

    Works like a charm.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies