This post was most recently updated on October 19th, 2022
Generally to retrieve details of an entry in contentful, we need to have the entry id. However in case we are not having an entry id and having the name or title of the entry then also we can fetch its details, provided we have the id of the content type of that particular entry. No two published entries of same content type can have same title.
Required parameters:
-> Title or name of the entry
-> Id of the content type
-> Space ID
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<span style="font-family: 'times new roman', times, serif">public async Task<string> GetAllEntriesForType() { string uniqueid = string.Empty; try { var queryBuilder = QueryBuilder<Entry<dynamic>>.New.FullTextSearch("<title of the entry>"); var entries = await _helper.GetClient().GetEntriesCollection<Entry<dynamic>>(queryBuilder,"<spaceID>", default); foreach (var s in entries.ToList()) { if (s.SystemProperties.ContentType.SystemProperties.Id == "<id of the content type>") { var id = s.SystemProperties.Id; uniqueid = id; } } return uniqueid; } catch (Exception ex) { _logger.LogError("Error in adding entry" + ex.Message); throw ex; } }</span> |