How To

List all Org Spaces and Apps

Here's a method that uses Project Automation to call the Podio API to list all Spaces and Apps and write them into a Podio App.

You can Download the Data Sync Project file to get started, then follow the steps below.

The Project Automation Code that this project uses is listed below:

using Simego.DataSync.Providers.Podio;

class ProjectAutomationOverride : Simego.DataSync.Automation.ProjectAutomationShim 
{    	
	public override void Start()
	{
		DataSourceA.GetDataTableCallback += GetDataTableSource;
	}
	
	public DataTableStore GetDataTableSource(DataTableStoreCallbackInfo info)
    {                                            		
		dynamic schema = DataSourceB.Podio.JsonRequest(new Uri("https://api.podio.com/org/"), "GET");

        foreach (var org in schema)
        {				
            foreach (var space in org["spaces"])
            {
				dynamic apps =  DataSourceB.Podio.JsonRequest(new Uri(string.Format("https://api.podio.com/app/space/{0}/", space["space_id"])), "GET");
				if(apps.Length > 0)
				{
					foreach(var app in apps)
					{
						info.Store.Rows.Add(info, (o, columnName) => {
							
							if(columnName == "OrgID")
							{
								return org["org_id"];
							}
							
							if(columnName == "OrgName")
							{
								return org["name"];
							}
							
							if(columnName == "SpaceID")
							{
								return space["space_id"];
							}
							
							if(columnName == "SpaceName")
							{
								return 	space["name"];
							}
							
							if(columnName == "AppID")
							{
								return app["app_id"];
							}
							
							if(columnName == "AppName")
							{
								return 	app["config"]["name"];
							}

							return null;
						});
					}
				}
            }
        }
										
        return info.Store;
    }
	```

## Create a Podio App
Create a Podio App to receive the data (this is needed as we get the Podio API Token form this connection in the code).

![Podio App](../../../../content/images/help_a7d512a4-c47b-4648-b9ee-6a70e11d315a.png "Podio App")

## Schema Mapping
Setup the Mapping to the Podio app.

![Schema Map](../../../../content/images/podioorgs_schema.png "Schema Map")

## Run the Compare
Run the compare by clicking ```Compare A->B``` and synchronise the results to populate the App with all the Spaces and Apps in the Org.

![Completed Results](../../../../content/images/help_ef51380a-fb85-40c8-8ebd-31ca14d3fcbf.png "Completed Results")