Contentful logo

Contentful Community

How get Entry with all localized fields

Hello. I’m using .Net sdk and don’t understand why _client.GetEntry<T>(entryId); return only en-US translation. How can I get all translations for “Resource” field?

Hi @maksimzalessky

You can specify which locale you wish to fetch content for by setting the locale query string parameter.

The SDK provides a helper class called QueryBuilder to help you with this. It could look something like this:

var qb = QueryBuilder<T>.New.LocaleIs("en-US");
var entry = await _client.GetEntry(entryId, qb);

It is recommended to use the GetEntries method if you need to also fetch referenced content from your entry. In that case you could do:

var qb = QueryBuilder<T>.New.LocaleIs("en-US").FieldEquals("", id);
var entry = await _client.GetEntries(qb).FirstOrDefault();
1 Like

Thanks @robert for help. So, we can get only one locale per request, is it right? I mean, if we need french locale, we should to do next:

var qb = QueryBuilder<T>.New.LocaleIs("fr-CA");
var entry = await _client.GetEntry<T>(entryId, qb);


You can actually get all the locales in one call by using * as the locale name. This will alter the structure of the returned JSON however and you would need to update your models accordingly.

1 Like

Great). You are best, @robert )). Thank you!