How can I get the content type of an entry?

Pretty simple question. I thought it would be in the sys node but that only tells me if it’s an entry or link. Any ideas?

This should be included in; however, if this is a reference field and you are using REST calls without leveraging one of the client libraries you will have to dig a little deeper. By default, full data for referenced entries are not included in the parent entry’s field data. Instead, you need to pass an include parameter, which will then add an includes array to the response. In this includes array you will find the full data for the referenced entry, which you can map to the field data on the parent via entry id. Hopefully this helps!

Are you trying to look for a specific type based on what’s in a rich text field?

If so, you need to catch two things, the BLOCKS or INLINES subtype (e.g. “BLOCKS.EMBEDDED_ASSET” and then the node inside of that. That node that it sounds like you found is correct, but it’s a few layers deeper than you might imagine (e.g. “sys?.contentType?.sys?.id”).

Here’s some sample code (React):

                switch (node?.data?.target?.fields?.file?.contentType){
                    case "application/pdf":
                        return <Button label={"Download PDF"} variant="secondary" url={`https:${node?.data?.target?.fields?.file?.url}`} />
                        return (
                switch(node?.data?.target?.sys?.contentType?.sys?.id) {
                    case "reference":
                        return <InlineReference {} />
                    case "button":
                        return <Button {} />