Get one or some fields from an entry

Hi,

Is it possible to only get some fields from an entry, rather than getting the entire thing?

Ex. I have several content items called ‘Project’ within each project entry there are a number of fields, references, and media items. I want to generate a list of all the project titles with their matching start dates. When you select a project, it will load all the relevant fields and media. I’d rather not have to get all the content for every project if I’m only ever going to be loading one at a time.

Any suggestions on how to go about this would be greatly appreciated.

Thanks!

This made me think. It sounds like GraphQL would be an interesting solution in this case and if I understood correctly the GraphQL content api is developed at the moment. So I am thinking you only query nodes inside of nodes, can you even do what you are asking with REST api and Json? Yeah, why not have every content piece as its own node you fetch. No idea:) Optional fields then again is different thing, there we still query everything but show only some of it.

i believe you’re looking for the select operator, described here in the REST API docs:

    const responseWithSelect = await client.getEntries({
        'content_type': 'yourContentId',
        'select': ['fields.name', 'fields.dateModified'].join(','),
    });

however, i̶ ̶j̶u̶s̶t̶ ̶f̶o̶u̶n̶d̶ ̶a̶ ̶b̶u̶g̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶f̶e̶a̶t̶u̶r̶e̶ ̶t̶h̶a̶t̶ ̶i̶’̶m̶ ̶g̶o̶i̶n̶g̶ ̶t̶o̶ ̶t̶r̶y̶ ̶t̶o̶ ̶w̶o̶r̶k̶ ̶o̶n̶ ̶g̶e̶t̶t̶i̶n̶g̶ ̶s̶u̶p̶p̶o̶r̶t̶ ̶o̶n̶
(edit 2/25/2020 - it was not a bug, i just misread the documentation - note the .join(',') i added to pass a comma-separated list to the SDK rather than an array

hope this works for your use case!

Thanks for the suggestion! That’s exactly what I was looking for, and it works as I hoped it would. :+1: