[i18n] How to update an existing localized collection entry per REST API or GraphQL?

System Information
  • Strapi Version: 3.6.2
  • Database: MongoDB

Hello,
maybe i am doing something wrong but i am not able to update an existing localized collection entry per REST API or GraphQL with non-default locale.
Creating it with the createlocalization is no problem, but how to update?

When i try with GraphQL i get Error: Cannot return null for non-nullable field Post.createdAt und trying with the REST API i get 401 - You cannot update this entry.
Both work fine when updating an entry with the default locale.

In the settings i do not find anything and in the docs it is not mentioned how to update an existing localized collection entry.

So, what am i doing wrong or is it not possible at the moment?

Wondering about this too!

Currently the documentation says that this is not possible:

It says the same for the REST api.

Can we get an update on when this will be possible? This to me is a very important feature.

1 Like

After thinking about this some more, I realized that this is only a problem with singleTypes. It’s not an issue with collectionTypes, because each localization has an id that you can access and use to update it. So I converted my singleType into a collection, and now it works. Where I was querying for the singleType before, now I’m querying for a collectionType by locale, and only using the first result in the data array. It’s not as intuitive as using a singleType, but it works.

1 Like

I still don’t understand how to update localized entries via REST API, without needing to process all the fields (which are common for all the locales).

So, for now, I have to do it like this:

// 1) Update the "primary" entry
const response = await axios.put(`${API_URL}${game_id}`, requestBody, config);

// 2) Get all available localizations for the entry
const localizationResponse = await axios.get(`${API_URL}${game_id}?populate=localizations`, config);
const localizations = localizationResponse.data?.data?.attributes?.localizations.data || [];

// 3) Update the same fields for the localized version of entry
for (const localization of localizations) {
	const locale_game_id = localization.id;  // use localization.id as key
	await axios.put(`${API_URL}${locale_game_id}`, requestBody, config);
}

Of course it looks like “workaround” :face_vomiting: