I am trying to figure out how to retrieve specific articles based on author (reference), my current function retrieves all articles, but I only want the author specific ones
const resp = yield client.getEntries({
'fields.insightsArticle': true,
'fields.excludeCountries[nin]': country,
'fields.publicationDate[lte]': moment(new Date()).toISOString(),
'fields.author.fields.firstname': author.firstName,
'fields.author.fields.lastname': author.lastName,
content_type: 'insight',
include: 2,
order: '-fields.publicationDate',
limit,
locale,
});
The current log I am getting from contentful is: "When searching on references you must specify the Content Type of the reference. Please send a Content Type id as a query parameter"
I get that, since I am defining the content type as insight.
Any suggestions are wele!
I am trying to figure out how to retrieve specific articles based on author (reference), my current function retrieves all articles, but I only want the author specific ones
const resp = yield client.getEntries({
'fields.insightsArticle': true,
'fields.excludeCountries[nin]': country,
'fields.publicationDate[lte]': moment(new Date()).toISOString(),
'fields.author.fields.firstname': author.firstName,
'fields.author.fields.lastname': author.lastName,
content_type: 'insight',
include: 2,
order: '-fields.publicationDate',
limit,
locale,
});
The current log I am getting from contentful is: "When searching on references you must specify the Content Type of the reference. Please send a Content Type id as a query parameter"
I get that, since I am defining the content type as insight.
Any suggestions are wele!
Share Improve this question asked Jul 9, 2019 at 11:49 Bram WesselinkBram Wesselink 1471 gold badge1 silver badge6 bronze badges1 Answer
Reset to default 11i had the same problem! you can specify the content type of the reference by adding:
'fields.author.sys.contentType.sys.id': 'author'
also, i would move the content_type: 'insight' line as the first entry and remove limit and locale since you're not using those fields.