Issue with GetContainers

Hi team,

I was trying to create a new Folder and create Data Types under that folder programmatically.
I managed to create the folder, but I can’t check or access it.
I need to check is there any folder with the mentioned name and if yes i need to create DataType under that.

I used the following code:

var allContainers = _dataTypeService.GetContainers(folderName, -1);

However, I’m not getting anything as a result.

Am I doing something wrong?
I’m stuck here, and any help would be greatly appreciated :face_with_spiral_eyes:

Thank you!

Are the containers actually present in the CMS? Can you see them in the backoffice?

The reason I’m asking is that people forget to explicitly save the container once created. Calling CreateContainer usually isn’t enough, you need to also use SaveContainer.

Hi @LuukPeters

Yes, I was able to save the container, and I can see the folder under the Data Type tree.

But when I try to access that folder (container), I’m getting null.
So, I tried to create it again — but now I get an error saying it already exists.
Due to this issue i need to manually create Folder and specify the parent id statically while creating datatypes.