Creating pages via REST API in a multi-language site

Ozgur Ozguven asked on June 24, 2015 18:27

I am programmatically creating pages in Kentico via REST API. All works fine for single-language sites. In a multiple-language sites, how can I create pages and its language variations. At the moment, I create them (wrongly) as seperate pages and that leads to duplication. What I mean by that is that if my site supports two languages, I end up with two seperate entries in a given language, one is fine and the other one appears as a 'not translated page'. Any help will be appericiated. Thanks..

Correct Answer

Timothy Fenton answered on June 25, 2015 15:23

Hello Ozgur

Please make sure you are using the correct format for the POST URL:

/content/site/<site name>/<culture>/document/<alias path>

the alias path is the full path of the first document you created, so if you are creating a new French culture version of the News page on CorporateSite it would be this:

~/rest/content/site/CorporateSite/fr-fr/document/News

then in the data you need to specify NodeID, however you should not explicitly set the DocumentID as this should automatically generate when adding the new culture version.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Roman Hutnyk answered on June 24, 2015 20:37 (last edited on June 24, 2015 20:38)

Ozgur,

This should help:

/content/currentsite/<culture>/document/<alias path> - creates a new page in the given culture for the site running on the domain in the base URL.
/content/site/<site name>/<culture>/document/<alias path> - creates a new page in the given culture on the specified site.

See documentation for more details.

Thanks

0 votesVote for this answer Mark as a Correct answer

Ozgur Ozguven answered on June 25, 2015 11:58

Thanks Roman.

But how will those two pages be related? My problem is that when I manually create a page in the main language, then switch to another language and there is already an entry in the content tree, but, it has not yet been created/translated. When I do create it through the UI manually, these two pages have the same NodeID, NodeGUID and DocumentNodeID. I need to repeat the same process via the REST API. But when I include NodeID of the first page I create in my HTTP POST, I get an error (Object reference not set to an instance of an object.)

How can I create the same page in multiple languages via the REST API?

Thanks

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.