I am moving our custom desktop (C#/WPF) Shotgun tools to the new Shotgun REST API and I have some questions:
- I am using var lEntity = JsonConvert.DeserializeObject<MyShotgunEntity>(lPayload) to convert the JSON payload into a C#.
- I then put the lEntity through a translation layer (DTO) to convert it to my application Model representation of the data.
- I am generating a unique class MyShotgunEntity for each Shotgun entity in my schema.
- I do this manually by retrieving a single entity of each type and creating a C# class for it using VisualStudio -> Edit -> Paste Special -> Paste JSON As Classes
- This works, but there are a number of issues with the processes:
- It is labour intensive.
- The classes generated are cluttered and need manual cleaning.
- The classes generated are dependent on the data in retrieve entity blob.
- The returned fields don’t always *appear* to be the correct type
- Some are string, int, bool etc.
- Some are objects (when they are string, int, bool etc)
- In the schema we currently use some of them are string?, int? bool? (nullable)
- So, do you have a better mechanism for easily (!?) getting a C# class that maps the JSON schema of entities within a Shogun database instance.
I think that covers all the current JSON / Schema issues
Now on to a couple of REST questions. I’m new to REST so please bear with me.
Here is an example of a body for a _search request
{
"filters": [ [ "project", "is", { "type": "Project", "id" : 143 } ] ],
"fields":["code", "description", "sg_status_list", "project"]
}
It filters all the requested entities for those with a project reference to Project.id 143
I am trying to work out how make the same call with an array of ids. i.e. [143, 156, 192, 200]
That is, do the same search, but for all entities with a reference to “one of these projects” (with the id in array)
Is this possible or do I need to add as many filters as there are items in the array?
I will be writing more complex filters where there may be multiple fields having such searches, so any help would be greatly appreciated.