Is there a way to get at linked/associated entity fields (like bubble querying in the SG api)?
For instance, if I want the sg_status_list
of an entity linked from a field in my search, do I have to make two queries (first for the linked entity, then for the fields on that entity) or is there an equivalent query to get the associated entity fields to be specified?
If I’m understanding it right you may want to do this via a deep field link?
This ony works on Single Entity fields, but essentially like this:
Find the episode name for my shot
filters = [["id", "is", SHOT_ID]]
fields = ["sg_sequence.Sequence.sg_episode.Episode.code"]
sg_shot = sg.find("Shot", filters, fields)
episode_name = sg_shot.get("sg_sequence.Sequence.sg_episode.Episode.code")
That’s exactly what I’m hoping for, but in the REST api; I only seem to be able to do it in the Python API. @Ricardo_Musch, is that the Python api or a wrapper around the REST api?
My code is for the python api.
Altough not sure if the python api wraps around the/a REST api…
…it does not; was hoping you had something custom…
1 Like
I’ve open Case number 20897217 in hopes that I can get some help figuring this out; as it is really expensive to have to do so many extra queries.
Hey, the REST works the same as Python API in that sense. You can do the same thing. For example, I use this search query in one of my projects and it works fine.
A POST request to https://indg.OURSTUDIO.com/api/v1/entity/PublishedFile/_search
{
"fields": "image,code,published_file_type,task,task.Task.step,name,version_number,created_at,sg_uploaded_file,entity",
"filters":[
[
"project.Project.sg_my_field",
"is",
{
"type": "CustomNonProjectEntity03",
"id": 123
}
],
[
"project",
"is",
{
"type": "Project",
"id": 123
}
],
[
"entity",
"type_is",
"Some_entity"
],
[
"sg_todelete",
"is",
false
]
],
"sort": "name",
"options": {"include_archived_projects": true}
}
So eventually it’s “field_name.Entity_type.field”. For example, to get a project name from a task you can say "project.Project.name"
. Keep in mind that the key name in the received dictionary will be exactly the same string
2 Likes