Open tylerwarner33 opened 2 weeks ago
Hi @tylerwarner33 ,
Look at the following snippet of code, how to cast folderContents.Data as FolderData or ItemData. Here is the link to the sample take a look at GetFolderContentsAsync method.
Let me know if this helps
`
public async Task GetFolderContentsAsync()
{
List
FolderContents folderContents = await dataManagementClient.GetFolderContentsAsync(projectId: project_id, folderId: folder_id, filterType: filter_type);
List<IFolderContentsData> folderContentsData = folderContents.Data;
foreach (var current in folderContentsData)
{
if (current is FolderData folder)
{
Console.WriteLine(folder.Id);
Console.WriteLine(folder.Type);
Console.WriteLine(folder.Relationships.Parent.Data.Type);
}
else if (current is ItemData item)
{
Console.WriteLine(item.Id);
Console.WriteLine(item.Type);
}
}
}
`
Hello @Arrotech, thank you, I did see that sample. It is helpful for being able to cast & use the data within the code.
But, is there a way for the data from the http response (image 1, includes data) to be passed to the JSON response (image 2, doesn't include data)?
Hi @tylerwarner33 ,
At the moment I would say, no. You have to cast as FolderData or ItemData to access their data. This issue is noted and will be fixed.
Let me know what is not working for you (the data you can't access) so that we can help.
Thanks for reporting.
Hi @tylerwarner33 - not sure I follow the issue completely. In the previous version, we had an issue where Foldercontents.Data would not return ItemData correctly. Since FolderContents can contain both FolderData & ItemData, in the new version we are now returning an Interface which needs to be cast and their data accessed. Let me know if I am missing something.
Hello @sajith-subramanian, maybe the last version wasn't working exactly right with both the FolderData & ItemData.
The issue I'm having with this version is when the FolderContents object is returned via an endpoint (a controller response in this case), the IFolderContentsData is not converting to JSON. So the "data" object in the JSON (images shown in the original post) is showing the correct number of items (FolderData & ItemData) in the array, but they are all empty [ {}, {}, {}, {}, {}, {}, {} ].
All of the data is there in the code, but not in the controller response (images shown in the original post).
The FolderContents class is using this data annotation [JsonConverter(typeof(FolderContentsDataConverter))]
for the conversion which is coming from the custom converter class FolderContentsDataConverter.
Let me know if you are getting a different result.
Thanks for the details @tylerwarner33 . We will log this for further investigation.
The Autodesk.DataManagement.Model.FolderContents result is returning correctly when I use this method:
As shown here:
However, FolderContents.Data (FolderContentsData) is not converting to JSON & therefore is not showing up in the response.
This was working in this previous version vs the current version.
Nuget package versions currently being used: