Error 404 when creating a languaje version of an existing page with Post

Yeray Campos asked on July 1, 2021 13:12

Hi

Im currently building a Dll that creates or edits pages in my company's Kentico Site and I having some issues posting Language Versions of the current content pages.

Right now, we have set Spanish(es-ES) as our default culture, when we create a Lenguaje Version of an existing page with Post we need the NodeID of the Spanish page first in order to link them, for example:

URL:
https://(OurSite)/rest/content/currentsite/it-IT/document/(ExistingDocumentAlias)?format=json
Post Data:
{  
    "NodeClassID": 7791,
    "DocumentName": "ExistingDocument",
     "NodeID": (existingDocumentNodeId in es-ES)
 }

 Response: 200 - OK

However when we want to create a contentpage in different cultures (e.g.it-IT and es-US) without creating one in the default culture(es-ES) we get this error:

First We make a new page:
https://(OurSite)/rest/content/currentsite/it-IT/document?format=json
Post Data:
{  
    "NodeClassID": 7791,
    "DocumentName": "NewDocument",

}
Response: 200 - OK

Then we make a new Lenguaje Version for that page:
https://(OurSite)/rest/content/currentsite/it-IT/document/(NewDocument)?format=json
Post Data:
{  
    "NodeClassID": 7791,
    "DocumentName": "NewDocument",
    "NodeID": (newDocumentNodeID)
}
Response: 404 - Not Found

Is there any way to creating lenguajes versions of pages without creating the default lenguaje version first?

Correct Answer

Juraj Ondrus answered on July 1, 2021 13:59

You need to have the page in the default culture first - without it you do not have the node record in the CMS_Tree table. So, the record in CMS_Document table for the language version has no node to be bound to. Please see the pages database structure to learn how things work. System expects to have the default culture node in the CMS_Tree table

0 votesVote for this answer Unmark Correct answer

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