'X-Language' header in REST API calls is ignored

Hello lovely Kirby community,

I’m trying to create some pages via the REST API endpoint api/pages/:id/children. I have a multi-language site with 2 languages (‘de’ and ‘en’). According to the documentation, I’m using the X-Language header to specify which language I want to use.

But when I create a new page, the header is being ignored. No matter which value I use, the page is created in the default language.

Here is my request (cURL syntax – exported from Postman):

curl --location --request POST ‘https://mypage.net/api/pages/imported-blog/children
–header ‘x-language: de’
–header ‘Authorization: Basic abc123’
–header ‘Content-Type: application/x-www-form-urlencoded’
–data-urlencode ‘template=blog’
–data-urlencode ‘slug=hallo-234’
–data-urlencode ‘content[text]=This is a test’

I get a 200 response from this request, but the page is only created in the default language, not in the desired language.

Any ideas why this happens?

Kirby always creates a page in the default language first. You probably need a follow up command that then updates the page in the target language, at least that how it works in the Panel. Because even when you have a non-default language selected in the Panel, only the default language version is created. The secondary language content file is only written once you hit save in the Panel.

You seem to be right. Thanks for this insight. This should be part of the documentation. I created a PR for this.

And now, the PR has been merged and the documentation has been updated. Gotta love the responsiveness of the Kirby team <3.