// Get the title field as dynamic.
dynamic title = entry.Get("title");
Get <T>
C#
1
2
3
public T Get<T>(string fieldName)
{
}
C#
1
2
// Get the title field as defined type
string title = entry.Get<string>("title");
Set
C#
1
2
3
public void Set(string fieldName, object value)
{
}
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
// Set a title string field value
entry.Set("title", "Star Trek - Into Darkness");
// Set a location object field value
entry.Set("filmingLocation", new Location(34.0943145, -118.3316929));
// Set an anonymous component field value
entry.Set("director",
new
{
Role = "Director",
Person = new Link("80c8e272-076e-41e0-84f4-753fc092a120")
}
);
C#
1
2
3
public void SetFile(string localFilePath, string filename = null)
{
}
C#
1
2
// Set new file for the asset with a filename override
entry.SetFile("c:\images\movies\batman.jpg", "Batman-returns.jpg");
SetFile (Stream)
C#
1
2
3
public void SetFile(Stream fileStream, string filename = null)
{
}
C#
1
2
3
4
5
6
// Get a file stream by downloading an image from a URL.
var stream = new HttpClient()
.GetStreamAsync("https://en.wikipedia.org/wiki/Batman_Returns#/media/File:Batman_returns_poster2.jpg");
// Set new file for the asset with a filename override
entry.SetFile(stream, "Batman-returns.jpg");
SetFile (byte array)
C#
1
2
3
public void SetFile(byte[] bytes, string filename = null)
{
}
C#
1
2
3
4
5
6
// Get a file stream by downloading an image from a URL.
var stream = new HttpClient()
.GetStreamAsync("https://en.wikipedia.org/wiki/Batman_Returns#/media/File:Batman_returns_poster2.jpg");
// Set new file for the asset with a filename override
entry.SetFile(stream, "Batman-returns.jpg");
HasValue
C#
1
2
3
public bool HasValue(string fieldName)
{
}
C#
1
2
3
4
5
if (entry.HasValue("title"))
{
// Get the location field as type
Location title = entry.Get<Location>("filmingLocation");
}
Save
C#
1
2
3
public void Save()
{
}
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Make a change to an entry.
entry.Set("title", "Forrest Gump");
try
{
// Save the changes.
entry.Save();
}
catch(RestRequestException restEx)
{
// Handle service error.
}
catch(ValidationException valEx)
{
// Handle data validation errors.
}
catch(Exception ex)
{
// Handle anything else, e.g. network error.
}
SaveAsync
C#
1
2
3
public async Task SaveAsync()
{
}
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Make a change to an entry
entry.Set("title", "Forrest Gump");
try
{
// Save the changes asynchronously.
entry.SaveAsnyc();
}
catch(RestRequestException restEx)
{
// Handle service error.
}
catch(ValidationException valEx)
{
// Handle data validation errors.
}
catch(Exception ex)
{
// Handle anything else, e.g. network error.
}
Delete
C#
1
2
3
public void Delete(bool permanent = false)
{
}
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
// Delete the entry variation to the recycle bin.
entry.Delete();
}
catch(RestRequestException restEx)
{
// Handle service error.
}
catch(ValidationException valEx)
{
// Handle data validation errors.
}
catch(Exception ex)
{
// Handle anything else, e.g. network error.
}
DeleteAsync
C#
1
2
3
public async Task DeleteAsync(bool permanent = false)
{
}
C#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
{
// Delete the entry variation permanently.
await entry.DeleteAsync(true);
}
catch(RestRequestException restEx)
{
// Handle service error.
}
catch(ValidationException valEx)
{
// Handle data validation errors.
}
catch(Exception ex)
{
// Handle anything else, e.g. network error.
}
NewVariation
C#
1
2
3
public Entry NewVariation(string language)
{
}
C#
1
2
3
4
5
6
7
8
// Create a new french variation
var frenchVariation = entry.NewVariation("fr-FR");
// Set some data for the variation
frenchVariation.Set("title", "Belle de Jour");
// Save the new variation
frenchVariation.Save();
Clone
C#
1
2
3
public Entry Clone()
{
}
C#
1
2
// Clones an existing entry variation.
var clonedEntry = existingEntry.Clone();
CloneAsync
C#
1
2
3
public async Task<Entry> CloneAsync()
{
}
C#
1
2
// Clones an existing entry variation asynchronously.
var clonedEntry = await existingEntry.CloneAsync();