Getting References by Id


#1

Hi Squidex Team,

I have a question how getting content of a references field by id. We have a Java Service which do the calls via REST to the Squidex API.

For example we have a page schema with field slider. The elements of the slider are schema teaser. So if I call this page I getting a JSON like this:

{
“slider”: “1dab58ef-1dab58ef-1dab58ef-1dab58ef”
}

In my code I have to know that the slider elements are of type teaser to get content with url …/teaser/1dab58ef…

Did you know another method to getting this content without to know that the slider elements are of type teaser?

Best regards,
Jens Lehmann


#2

Hi, Jens,

you have three options:

  1. You hardcode it in your code that the id is of type teaser.
  2. You query the schema of the parent type.
  3. You use graphql.

#3

Hi Sebastian,

how can I do the 2nd method?

Best regards,
Jens Lehmann


#4

See the following API: https://cloud.squidex.io/api/docs#operation/Schemas_GetSchema


#5

Hi Sebastian,

thanks, for your reply. Is it also possible that the API have a generic interface to get content by id e.g. …/content/123-123-123-123-123 in one of the next releases?

Best regards,
Jens Lehmann


#6

I have to check the priorities, because it is a bigger task than you might think. The usual flow is to resolve the app, then the schema, then the content and I have to change this for this requirement.

Can you create a feature request for it?