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?
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("sys.id", id);
var entry = await _client.GetEntries(qb).FirstOrDefault();
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);
etc.
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.
Hi , Does using * work using the graph QL API ? I am getting the below error
“Query execution error. Requested locale ‘*’ does not exist in the space”"