Error in validation/error message for creating translations for categories and sections | Community
Skip to main content

Error in validation/error message for creating translations for categories and sections

  • July 24, 2023
  • 2 replies
  • 0 views

There is an error in validation for creating translations for categories and sections. The returned error is "Name cannot be blank" however what it is actually validating on is "Title."

for sectionLocale in missingSectionTranslations:
#create a new section for each translation
payload["translation"]["locale"] = sectionLocale
payload["translation"]["title"] = payload["translation"]["name"]
response = requests.request(
"POST",
c.URL+"sections/"+str(section["id"])+"/translations",
json=payload,
auth=(c.USER,c.PASSWORD),
headers=c.HEADERS
)

2 replies

Hi Ross,
 
Does the parent category of this new section translation have a translation for that locale as well?  So for example if you're trying to add an en-au translation to a section, does that section's parent category have an en-au translation?

  • Author
  • August 2, 2023

Yes, the issue also occurred with categories. The solution to get a 200 was to simply add a "title" key to the json. Once I did that it passed the name:cannot be blank validation.

Either the validation error returned on a 400 needs to be updated to specify title instead of name, or there is unneeded validation looking for title when it is not required. I believe it may be the latter as "title" is not listed as a property on category or section.

payload["translation"]["title"] = payload["translation"]["name"]