Show / Hide Table of Contents

Space and content types

You can retrieve information about your space and content types. This can be useful when modeling or presenting content model.

Get the space

var space = await _client.GetSpaceAsync();

Console.WriteLine(space.Name); // => SpaceName
Console.WriteLine(space.SystemProperties.Type); // => Space
Console.WriteLine(space.Locales.Count.ToString()); // => 2
Console.WriteLine(space.Locales[0].Code); // => en-US
Console.WriteLine(space.Locales[1].Name); // => Swedish

Get a content type

var contentType = await _client.GetContentTypeAsync("someid");

Console.WriteLine(contentType.Name); // => Product
Console.WriteLine(contentType.DisplayField); // => productName
Console.WriteLine(contentType.Fields.Count.ToString()); // => 12
Console.WriteLine(contentType.Fields[0].Localized.ToString()); // => true
Console.WriteLine(contentType.Fields[0].Required.ToString()); // => true
Console.WriteLine(contentType.Fields[2].Name); // => Description

Get all content types

var contentTypes = await _client.GetContentTypesAsync();

Console.WriteLine(contentTypes.Count().ToString()); // => 3
Console.WriteLine(contentTypes.First().Name); // => Brand
Back to top Copyright © 2015-2016 Contentful
Generated by DocFX