-
Notifications
You must be signed in to change notification settings - Fork 34
Documentation
The AirtableBase type exposes the following members.
Name | Description |
---|---|
public AirtableBase(string, string) | initializes a new instance of AirtableBase with a specific API key or an access token, and a specific Base ID |
public AirtableBase(string, string, DelegatingHandler) | initializes a new instance of AirtableBase with a specific API key or an access token, a specific Base ID, and a customized HTTP delegating handler |
public AirtableBase(HttpClient, string, string) | initializes a new instance of AirtableBase with a HttpClient, a specific API key or an access token, a specific Base ID |
Name | Description |
---|---|
ShouldNotRetryIfRateLimited | Gets or sets a value which indicates whether retries should not be allowed if the user has sent too many requests in a given amount of time. This value is set to 'false' by default meaning retries are allowed. |
RetryDelayMillisecondsIfRateLimited | Gets or sets the initial number of milliseconds to wait before sending the same request again if the previous request resulted in a HttpStatusCode 429 for Too Many Requests. The default value is 2000 milliseconds. The maximum number of retries is 3 and the delay increase exponentially with an exponent of 2 for each subsequent retry. |
Name | Description |
---|---|
GetUserIdAndScopes(CancellationToken) | Get the user ID of the access token and the scopes granted to this user ID. |
ListRecords(string, string, IEnumerable, string int?, int?, IEnumerable, string, string, string, string, bool, bool?, CancellationToken) | Get a list of records in a specific table as an asynchronous operation. |
ListRecords<T> (string, string, IEnumerable, string int?, int?, IEnumerable, string, string, string, string, bool, bool?, CancellationToken) |
Get a list of record<T> in a specific table as an asynchronous operation. The fields of each record are deserialized to type <T> . |
RetrieveRecord(string, string, string, string, bool), CancellationToken | Retrieve a record with a specific id from a specific table as an asynchronous operation. |
RetrieveRecord<T> (string, string, string, string, bool, CancellationToken) |
Retrieve a record<T> with a specific id from a specific table as an asynchronous operation. The fields of the retrieved record are deserialized to type <T> . |
CreateRecord(string, Fields, bool, CancellationToken) | Create a record in a specific table using information provided by caller as an asynchronous operation. |
UpdateRecord(string, Fields, string, bool, CancellationToken) | Update a record with a specific ID in a specific table as an asynchronous operation. |
ReplaceRecord(string, Fields, string, bool, CancellationToken) | Replace a record with a specific ID in a specific table as an asynchronous operation. |
DeleteRecord(string, string, CancellationToken) | Delete a record with a specific ID in a specific table as an asynchronous operation. |
CreateMultipleRecords(string, Fields[], bool, CancellationToken) | Create multiple records in a specific table using information stored in Fields[] provided by caller in a single asynchronous operation. |
CreateMultipleRecords(string, AirtableRecord[], bool, CancellationToken) | Create multiple records in a specific table using information stored in AirtableRecord[] provided by caller in a single asynchronous operation. |
UpdateMultipleRecords(string, IdFields[], bool, bool, PerformUpsert, CancellationToken) | Update multiple records in a specific table using information stored in IdFields[] provided by caller in a single asynchronous operations. |
UpdateMultipleRecords(string, AirtableRecord[], bool, bool, PerformUpsert, CancellationToken) | Update multiple records in a specific table using information stored in AirtableRecord[] provided by caller in a single asynchronous operations. |
ReplaceMultipleRecords(string, IdFields[], bool, bool, PerformUpsert, CancellationToken) | Replace multiple records in a specific table using information stored in IdFields[] provided by caller in a single asynchronous operation. |
ReplaceMultipleRecords(string, AirtableRecord[], bool, bool, PerformUpsert, CancellationToken) | Replace multiple records in a specific table using information stored in AirtableRecord[] provided by caller in a single asynchronous operation. |
ListComments(string, string, string, int?, CancellationToken) | Get the comment list for the record specified by caller in a single asynchronous operation. |
CreateComment(string, string, string, CancellationToken) | Create a comment for the record specified by caller in a single asynchronous operation. |
UpdateComment(string, string, string, CancellationToken) | Update a comment row for the record specified by caller in a single asynchronous operation. |
DeleteComment(string, string, string, CancellationToken) | Delete a comment row for the record specified by caller in a single asynchronous operation. |
CreateWebhook(WebhooksSpecification, string, CancellationToken) | Create a Webhook in the base specified in the specification. Payloads may be generated and the notification URL (if given) will get a ping shortly after this completes. |
ListWebhooks(CancellationToken) | Lists all webhooks that are registered for a base, along with their statuses. |
ListPayloads(string, int, int?, CancellationToken) | Enumerate the update messages for a client to consume. Clients should call this after they receive a ping. |
EnableWebhookNotifications(string, bool, CancellationToken) | Enables or disables notification pings for a webhook. |
RefreshWebhook(string, CancellationToken) | Extend the life of a webhook. The new expiration time will be 7 days after the refresh time. |
DeleteWebhook(string, CancellationToken) | Deletes a webhook. |
Dispose() | Releases the unmanaged resources and disposes of the managed resources used by the class |
AirtableBase.GetUserIdAndScopes (CancellationToken)
Get the user ID of the access token and the scopes granted to this access token as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableGetUserIdAndScopesResponse> GetUserIdAndScopes(Cancellation token = default(CancellationToken))
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKeyOrAccessToken = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableDeleteRecordResponse> task = airtableBase.GetUserIdAndScopes();
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
Airtable.ListRecords(string, string, IEnumerable, string, int?, int?, IEnumerable<Sort>, string, string, string, string, bool, bool?, CancellationToken))
Get a list of records in a specific table. Start the listing at a specific offset. Specify what fields should be included in the record together with a specific filter formula, the number of records per page. Specify how the record list should be sorted and from which view of the table. This method is an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableListRecordsResponse> ListRecords(
string tableIdOrName,
string offset = null,
IEnumerable<string> fields = null,
string filterByFormula = null,
int? maxRecords = null,
int? pageSize = null,
IEnumerable<Sort> sort = null,
string view = null,
string cellFormat = null,
string timeZone = null,
string userLocale = null,
bool returnFieldsByFieldId = false,
bool? includeCommentCount = null,
CancellationToken token = default(CancellationToken))
Type: string
Name of the table of which the records to be retrieved from
Type: string
offset into the table where the record listing starts
Type: Inumerable<string>
Only data for fields whose names or ID's are in this list will be included in the records. If you
don't need every field, you can use this parameter to reduce the amount of data transferred.
Type: string
A formula used to filter records. The formula will be evaluated for each record, and if the
result is not 0, false, "", NaN, [], or #Error! the record will be included in the response.
Type: int
The maximum total number of records that will be returned.
Type: int
The number of records returned in each request. Must be less than or equal to 100.
Default is 100.
Type: Sort
A list of Sort objects that specifies how the records will be ordered. Each Sort
object must have a field key specifying the name of the field to sort on, and an
optional direction key that is either Direction.Asc or Direction.Desc. The default
direction is Direction.Asc.
Type: string
The name or ID of a view in the Artists table. If set, only the records in that view
will be returned. The records will be sorted according to the order of the view.
Type: string
The format that should be used for cell values. Supported values are:
json: cells will be formatted as JSON, depending on the field type.
string: cells will be formatted as user-facing strings, regardless of the field type.
The timeZone and userLocale parameters are required when using string as the cellFormat.
Type: string
The time zone that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: string
The user locale that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: bool
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: bool?
An optional field that, if specified, includes commentCount on each record returned.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
Returned records do not include any fields with "empty" values, e.g. "", [], or false.
The server returns one page of records at a time. Each page will contain pageSize records, which is 100 by default.
If there are more records, the response will contain an offset. To fetch the next page of records, include offset in the next request's parameters
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
string offset = null;
string errorMessage = null;
var records = new List<AirtableRecord>();
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
//
/ Use 'offset' and 'pageSize' to specify the records that you want
// to retrieve.
// Only use a 'do while' loop if you want to get multiple pages
// of records.
//
do
{
Task<AirtableListRecordsResponse> task = airtableBase.ListRecords(
YOUR_TABLE_NAME,
offset,
fields,
filterByFormula,
maxRecords,
pageSize,
sort,
view,
cellFormat
timeZone,
userLocale,
returnFieldsByFieldId,
includeCommentCount,
token)
AirtableListRecordsResponse response = await task;
if (response.Success)
{
records.AddRange(response.Records.ToList());
offset = response.Offset;
}
else if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
break;
}
else
{
errorMessage = "Unknown error";
break;
}
} while (offset != null);
}
if (!string.IsNullOrEmpty(errorMessage))
{
// Error reporting
}
else
{
// Do something with the retrieved 'records' and the 'offset'
// for the next page of the record list.
}
Airtable.ListRecords<T>
(string, string, IEnumerable, string, int?, int?, IEnumerable<Sort>, string, string, string, string, bool, bool?, CancellationToken)
Get a list of record<T>
in a specific table as an asynchronous operation. The fields of each record are deserialized to type <T>
. Start the listing at a specific offset. Specify what fields should be included in the record together with a specific filter formula, the number of records per page. Specify how the record list should be sorted and from which view of the table. This method is an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableListRecordsResponse<T>> ListRecords<T>(
string tableIdOrName,
string offset = null,
IEnumerable<string> fields = null,
string filterByFormula = null,
int? maxRecords = null,
int? pageSize = null,
IEnumerable<Sort> sort = null,
string view = null,
string cellFormat = null,
string timeZone = null,
string userLocale = null,
bool returnFieldsByFieldId = false,
bool? includeCommentCount = null,
Cancellation token = default(CancellationToken))
Type: string
Name of the table of which the records to be retrieved from
Type: string
offset into the table where the record listing starts
Type: Inumerable<string>
Only data for fields whose names or ID's are in this list will be included in the records. If you
don't need every field, you can use this parameter to reduce the amount of data transferred.
Type: string
A formula used to filter records. The formula will be evaluated for each record, and if the
result is not 0, false, "", NaN, [], or #Error! the record will be included in the response.
Type: int
The maximum total number of records that will be returned.
Type: int
The number of records returned in each request. Must be less than or equal to 100.
Default is 100.
Type: Sort
A list of Sort objects that specifies how the records will be ordered. Each Sort
object must have a field key specifying the name of the field to sort on, and an
optional direction key that is either Direction.Asc or Direction.Desc. The default
direction is Direction.Asc.
Type: string
The name or ID of a view in the Artists table. If set, only the records in that view
will be returned. The records will be sorted according to the order of the view.
Type: string
The format that should be used for cell values. Supported values are:
json: cells will be formatted as JSON, depending on the field type.
string: cells will be formatted as user-facing strings, regardless of the field type.
The timeZone and userLocale parameters are required when using string as the cellFormat.
Type: string
The time zone that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: string
The user locale that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: bool
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: bool?
An optional field that, if specified, includes commentCount on each record returned.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
Returned records do not include any fields with "empty" values, e.g. "", [], or false.
The server returns one page of records at a time. Each page will contain pageSize records, which is 100 by default.
If there are more records, the response will contain an offset. To fetch the next page of records, include offset in the next request's parameters
The class Artist is used to encapsulate all fields of each record of the
Artists table to be used in this example.
In this process we need to make sure that all Airtable field names are
valid C# field names by making use of the [JsonProperty("AirtableFieldName"]
annotation; see JsonProperty("On Display?")] below as an example.
public class Artist
{
public string Name { get; set; }
public List<AirtableAttachment> Attachments { get; set; }
public string Bio { get; set; }
[JsonProperty("On Display?")]
public bool OnDisplay { get; set; }
public List<string> Collection { get; set; }
public List<string> Genre { get; set; }
}
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
string offset = null;
string errorMessage = null;
var records = new List<AirtableRecord<Artist>();
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
//
/ Use 'offset' and 'pageSize' to specify the records that you want
// to retrieve.
// Only use a 'do while' loop if you want to get multiple pages
// of records.
//
do
{
Task<AirtableListRecordsResponse<Artist>> task = airtableBase.ListRecords<Artist>(
ARTISTS_TABLE_NAME,
offset,
fields,
filterByFormula,
maxRecords,
pageSize,
sort,
view,
cellFormat,
timeZone,
userLocale,
returnFieldsByFieldId,
includeCommentCount);
AirtableListRecordsResponse response = await task;
if (response.Success)
{
records.AddRange(response.Records.ToList());
offset = response.Offset;
}
else if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
break;
}
else
{
errorMessage = "Unknown error";
break;
}
} while (offset != null);
}
if (!string.IsNullOrEmpty(errorMessage))
{
// Error reporting
}
else
{
// Do something with the retrieved 'records' and the 'offset'
// for the next page of the record list.
// See how to extract fields of each record as an instance of Artist in the example section below
}
// Retrieve all fields of the 1st record from an instance of Artist.
// If the first Artist record in the list is Al Held then:
Artist AlHeld = response.RecordList[0].Fields;
Assert.AreEqual(AlHeld.Name, "Al Held");
Assert.IsTrue(AlHeld.OnDisplay);
Assert.AreEqual(AlHeld.Collection.Count, 1);
Assert.AreEqual(AlHeld.Genre.Count, 2);
Assert.IsNotNull(AlHeld.Bio);
Assert.AreEqual(AlHeld.Attachments.Count, 4);
Airtable.RetrieveRecord(string, string, CancellationToken))
Retrieve a record with a specific ID from a specific table as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableRetrieveRecordResponse> RetrieveRecord(
string tableIdOrName,
string id,
string cellFormat = null,
string timeZone = null,
string userLocale = null,
bool returnFieldsByFieldId = false,
Cancellation token = default(CancellationToken))
Type: string
Name of the table of which the record to be retrieved from
Type: string
ID of the record to be retrieved.
Type: string
The format that should be used for cell values. Supported values are:
json: cells will be formatted as JSON, depending on the field type.
string: cells will be formatted as user-facing strings, regardless of the field type.
The timeZone and userLocale parameters are required when using string as the cellFormat.
Type: string
The time zone that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: string
The user locale that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: bool
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read. Any "empty" fields (e.g. "", [], or false) in the record will not be returned. In attachment objects included in the retrieved record (Attachments), only id, url, and filename are always returned. Other attachment properties may not be included.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableRetrieveRecordResponse> task = airtableBase.RetrieveRecord(YOR_TABLE_NAME, ID_OF_RECORD_TO_RETRIEVE);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
var record = response.Record;
// Do something with your retrieved record.
// Such as getting the attachmentList of the record if you
// know the Attachment field name
var attachmentList = response.Record.GetAttachmentField(YOUR_ATTACHMENT_FIELD_NAME);
}
}
Airtable.RetrieveRecord,T>(string, string, CancellationToken token)
Retrieve a record with a specific ID from a specific table as an asynchronous operation.
The fields of the retrieved record are deserialized in type <T>
.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableRetrieveRecordResponse<T>> RetrieveRecord<T>(
string tableIdOrName,
string id,
string cellFormat = null,
string timeZone = null,
string userLocale = null,
bool returnFieldsByFieldId = false,
Cancellation token = default(CancellationToken))
Type: string
Name of the table of which the record to be retrieved from
Type: string
ID of the record to be retrieved.
Type: string
The format that should be used for cell values. Supported values are:
json: cells will be formatted as JSON, depending on the field type.
string: cells will be formatted as user-facing strings, regardless of the field type.
The timeZone and userLocale parameters are required when using string as the cellFormat.
Type: string
The time zone that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: string
The user locale that should be used to format dates when using string as the cellFormat. This parameter is required when using string as the cellFormat.
Type: bool
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read. Any "empty" fields (e.g. "", [], or false) in the record will not be returned. In attachment objects included in the retrieved record (Attachments), only id, url, and filename are always returned. Other attachment properties may not be included.
The class Artist is used to encapsulate all fields of each record of the Artists
table. In this process we need to make sure that all Airtable field names are
valid C# field names by making use of the [JsonProperty("AirtableFieldName")]
annotation; see [JsonProperty("On Display?")] below as an example.
public class Artist
{
public string Name { get; set; }
public List<AirtableAttachment> Attachments { get; set; }
public string Bio { get; set; }
[JsonProperty("On Display?")]
public bool OnDisplay { get; set; }
public List<string> Collection { get; set; }
public List<string> Genre { get; set; }
}
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableRetrieveRecordResponse<Artist> task = airtableBase.RetrieveRecord<Artist>(ARTISTS_TABLE_NAME, ID_OF_RECORD_TO_RETRIEVE);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
// Do something with your retrieved record.
// See how to extract fields of the retrieved record as an instance of Artist in the example section below
}
}
// Assuming ID_OF_RECORD_TO_RETRIEVE is the Id string of Miya Ando then all test results should be as expected.
Assert.IsTrue(string.Compare(response.Record.Id, ID_OF_RECORD_TO_RETRIEVE) == 0);
// Abstract all fields of the record as an instance of Artist.
Artist MiyaAndo = response.Record.Fields;
Assert.AreEqual(MiyaAndo.Name, "MiyaAndo");
Assert.IsFalse(MiyaAndo.OnDisplay);
Assert.AreEqual(MiyaAndo.Collection.Count, 1);
Assert.AreEqual(MiyaAndo.Genre.Count, 2);
Assert.IsNotNull(MiyaAndo.Bio);
Assert.AreEqual(MiyaAndo.Attachments.Count, 4);
AirtableBase.CreateRecord( string, Fields, bool, CancellationToken)
Create a record in a specific table using provided information as an asynchronous operation. To create new attachments in an attachment field, set the field value to an array of attachment objects. When creating an attachment, url is required, and filename is optional. Airtable will download the file at the given url and keep its own copy of it. All other attachment object properties will be generated server-side soon afterward.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateReplaceRecordResponse> CreateRecord(
string tableIdOrName,
Fields fields,
bool typecast = false,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record will be created
Type: Fields parameter representing the fields in the record to be created.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read. You can include all, some, or none of the field values. Returns the created record object if the call succeeded, including a record ID which will uniquely identify the record within the specified table.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
// Create Attachments list
var attachmentList = new List<AirtableAttachment>();
attachmentList.Add(new AirtableAttachment { Url = "https://upload.wikimedia.org/wikipedia/en/d/d1/Picasso_three_musicians_moma_2006.jpg" });
var fields = new Fields();
fields.AddField("Name", "Pablo Picasso");
fields.AddField("Bio", "Spanish expatriate Pablo Picasso was one of the greatest and most influential artists of the 20th century, as well as the co-creator of Cubism.");
fields.AddField("Attachments", attachmentList);
fields.AddField("On Display?", false);
Task<AirtableCreateUpdateReplaceRecordResponse> task = airtableBase.CreateRecord(tableIdOrName, fields, true);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
var record = response.Record;
// Do something with your created record.
}
}
AirtableBase.UpdateRecord(string, Fields, string, bool, CancellationToken)
Update some (but not all) fields of a record in a specific table using provided information as an asynchronous operation. Any fields that are not included will not be updated.
To add attachments to an attachment field, add new attachment objects to the existing array. Be sure to include all existing attachment objects that you wish to retain. For the new attachments being added, url is required, and filename is optional. To remove attachments, include the existing array of attachment objects, excluding any that you wish to remove.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateReplaceRecordResponse> UpdateRecord(
string tableIdOrName,
Fields fields,
string id,
bool typeCast = false,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record will be updated
Type: Fields parameter representing the fields in the record to be updated.
Type: string
ID of the record to be updated.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
var fields = new Fields();
fields.AddField("Name", "Pablo Picasso Updated");
fields.AddField("On Display?", true);
Task<AirtableCreateUpdateReplaceRecordResponse> task = airtableBase.UpdateRecord(tableIdOrName, fields, ID_OF_RECORD_TO_UPDATE);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
var record = response.Record;
// Do something with your updated record.
}
}
AirtableBase.ReplaceRecord(string, Fields, string, bool, CancellationToken)
Replace a record with a specific ID in a specific table using provided information as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateReplaceRecordResponse> ReplaceRecord(
string tableIdOrName,
Fields fields,
string id,
bool typeCast = false,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record will be replaced with information provided by caller.
Type: Fields parameter representing the fields in the record to be replaced. Any fields that are not included will be cleared.
Type: string
ID of the record to be replaced.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
var fields = new Fields();
fields.AddField("Name", "Pablo Picasso Replaced");
fields.AddField("On Display?", true);
var attachment1 = new AirtableAttachment { Url = "https://upload.wikimedia.org/wikipedia/en/d/d1/Picasso_three_musicians_moma_2006.jpg" };
var attachment2 = new AirtableAttachment { Url = "https://upload.wikimedia.org/wikipedia/en/thumb/6/6a/Pablo_Picasso%2C_1921%2C_Nous_autres_musiciens_%28Three_Musicians%29%2C_oil_on_canvas%2C_204.5_x_188.3_cm%2C_Philadelphia_Museum_of_Art.jpg/800px-Pablo_Picasso%2C_1921%2C_Nous_autres_musiciens_%28Three_Musicians%29%2C_oil_on_canvas%2C_204.5_x_188.3_cm%2C_Philadelphia_Museum_of_Art.jpg" };
var attachmentList = new List<AirtableAttachment>();
attachmentList.Add(attachment1);
attachmentList.Add(attachment1);
fields.AddField("Attachments", attachmentList);
Task<AirtableCreateUpdateReplaceRecordResponse> task = airtableBase.ReplaceRecord(tableIdOrName, fields, ID_OF_RECORD_TO_BE_REPLACED);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
var record = response.Record;
// Do something with your replaced record.
}
}
AirtableBase.DeleteRecord(string, string, CancellationToken))
Delete a record with a specific ID in a specific table as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableDeleteRecordResponse> DeleteRecord(
string tableIdOrName,
string id,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record will be deleted
Type: string
ID of the record to be deleted.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableDeleteRecordResponse> task = airtableBase.DeleteRecord(YOUR_TABLE_NAME, ID_OF_RECORD_TO_DELETE);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.CreateMultipleRecords(string, Fields[], bool, CancellationToken))
Create multiple records in a specific table using provided information in a single an asynchronous operation. The fields of each record are provided in a Fields[]. To create new attachments in an attachment field, set the field value to an array of attachment objects. When creating an attachment, url is required, and filename is optional. Airtable will download the file at the given url and keep its own copy of it. All other attachment object properties will be generated server-side soon afterward.
**Namespace: AirtableApiClient
**Assembly: AirtableApiClient.dll
##Syntax
public async Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> CreateMultipleRecords(
string tableIdOrName,
Fields[] fields,
bool typecast = false,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record will be created
Type: [Fields](https://github.com/ngocnicholas/airtable.net/wiki/Fields)
parameter representing the fields in the record to be created.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read. You can include all, some, or none of the field values. Returns the created record list object if the call succeeded. Each record in the list has a record ID which will uniquely identify the record within the specified table.
##Example
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Fields[] fields = new Fields[2];
fields[0] = new Fields();
fields[0].AddField("Name", "Claude Monet");
fields[0].AddField("Bio", "Oscar-Claude Monet was a French painter, a founder of French Impressionist painting and the most consistent and prolific practitioner of the movement's philosophy of expressing one's perceptions before nature, especially as applied to plein air landscape painting");
fields[1] = new Fields();
fields[1].AddField("Name", "Vincent van Gogh");
fields[1].AddField("Bio", "Vincent Willem van Gogh was a Dutch post-impressionist painter who is among the most famous and influential figures in the history of Western art. In just over a decade he created about 2,100 artworks, including around 860 oil paintings, most of them in the last two years of his life.");
Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> task = airtableBase.CreateMultipleRecords(TABLE_NAME, fields, true);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
AirtableRecord[] records = response.Records;
// Do something with your created records.
}
}
AirtableBase.CreateMultipleRecords(string, AirtableRecord[], bool, CancellationToken))
Create multiple records in a specific table using provided information in a single an asynchronous operation. The fields information for the records to be created are provided in a AirtableRecord[]. To create new attachments in an attachment field, set the field value to an array of attachment objects. When creating an attachment, url is required, and filename is optional. Airtable will download the file at the given url and keep its own copy of it. All other attachment object properties will be generated server-side soon afterward.
**Namespace: AirtableApiClient
**Assembly: AirtableApiClient.dll
##Syntax
public async Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> CreateMultipleRecords(
string tableIdOrName,
AirtableRecord[] records,
bool typecast = false,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record will be created
Type: AirtableRecord[] parameter representing the fields information of the records to be created.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read. You can include all, some, or none of the field values. Returns the created record list object if the call succeeded. Each record in the list has a record ID which will uniquely identify the record within the specified table.
##Example
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
// Do something to obtain the fields information of the records to be created and store it in AirtableRecord[] records.
// This AirtableRecord[] records has the same syntax as AirtableListRecordsResponse.Records returned by ListRecords().
Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> task = airtableBase.CreateMultipleRecords(TABLE_NAME, records);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
AirtableRecord[] records = response.Records;
// Do something with your created records.
}
}
AirtableBase.UpdateMultipleRecords(string, IdFields[], bool, CancellationToken)
Update one or more records in a specific table using provided information in a single asynchronous operation. Any fields that are not included in the provided information will not be updated.
To add attachments to an attachment field, add new attachment objects to the existing array. Be sure to include all existing attachment objects that you wish to retain. For the new attachments being added, url is required, and filename is optional. To remove attachments, include the existing array of attachment objects, excluding any that you wish to remove.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> UpdateMultipleRecords(
string tableIdOrName,
IdFields[] idFields,
bool typeCast = false,
returnFieldsByFieldId false,
performUpsert = null,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record(s) will be updated
Type: IdFields An array of ID and fields of the records to be updated.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: boolean
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: PerformUpsert
Optional. Enable/Disable upsert behavior. When upserting is enabled, the id property of records becomes optional.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
IdFields[] idFields = new IdFields[2];
idFields[0] = new IdFields(ID_MONET_TO_UPDATE);
idFields[0].AddField("On Display?", true);
idFields[1] = new IdFields(ID_VANGOGH_TO_UPDATE);
idFields[1].AddField("Name", "UpdatedNameVincentVanGogh");
Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> task = airtableBase.UpdateMultipleRecords(TABLE_NAME, idFields);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
AirtableRecord[] records = response.Records;
// Do something with the updated records.
}
}
AirtableBase.UpdateMultipleRecords(string, [AirtableRecord](AirtableRecord, bool, CancellationToken))
Update one or more records in a specific table using provided information in a single asynchronous operation. Any fields (in the input records) that are not included in the provided information will not be updated.
To add attachments to an attachment field, add new attachment objects to the existing array. Be sure to include all existing attachment objects that you wish to retain. For the new attachments being added, url is required, and filename is optional. To remove attachments, include the existing array of attachment objects, excluding any that you wish to remove.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> UpdateMultipleRecords(
string tableIdOrName,
AirtableRecord[] records,
bool typeCast = false,
returnFieldsByFieldId = false,
performUpsert = null,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record(s) will be updated
Type: AirtableRecord parameter representing the records to be updated with the new fields stored in this parameters.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: boolean
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: PerformUpsert
Optional. Enable/Disable upsert behavior. When upserting is enabled, the id property of records becomes optional.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
// Do something to obtain a AirtableRecord[] records to use as an input argument.
// This AirtableRecord[] records has the same syntax as AirtableListRecordsResponse.Records returned by ListRecords().
// The fields of input records are the fields to be used in this update operation.
Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> task = airtableBase.UpdateMultipleRecords(TABLE_NAME, records);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
}
else
{
errorMessage = "Unknown error";
}
// Report error message
}
else
{
AirtableRecord[] records = response.Records;
// Do something with the updated records.
}
}
AirtableBase.ReplaceMultipleRecords(string, IdFields), bool, CancellationToken))
Replace one or more records in a specific table using provided information in a single asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> ReplaceMultipleRecords(
string tableIdOrName,
IdFields[] idFields,
bool typeCast = false,
returnFieldsByFieldId,
performUpsert = null,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record(s) will be replaced
Type: IdFields An array of ID and fields of the records to be updated.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: boolean
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: PerformUpsert
Optional. Enable/Disable upsert behavior. When upserting is enabled, the id property of records becomes optional.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
IdFields[] idFields = new IdFields[2];
idFields[0] = new IdFields(ID_MONET_TO_REPLACE);
idFields[0].AddField("Name", "Claude Monet");
idFields[0].AddField("On Display?", true);
idFields[1] = new IdFields(ID_VANGOGH_TO_REPLACE);
idFields[1].AddField("Name", "Vincent VanGogh replaced");
Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> task = airtableBase.ReplaceMultipleRecords(TABLE_NAME, idFields);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
else if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
AirtableRecord[] records = response.Records;
// Do something with the replaced records
}
}
AirtableBase.ReplaceMultipleRecords(string, AirtableRecord, bool, CancellationToken))
Replace one or more records in a specific table using provided information in a single asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> ReplaceMultipleRecords(
string tableIdOrName,
AirtableRecord[] records,
bool typeCast = false,
returnFieldsByFieldId = false,
performUpsert = null,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record(s) will be replaced
Type: [AirtableRecord](https://github.com/ngocnicholas/airtable.net/wiki/AirtableRecord)
parameter representing the fields in the record to be updated.
Type: bool
Enable/Disable automatic data conversion. Automatic conversion is disabled by default to
ensure data integrity, but it may be helpful for integrating with 3rd party data sources.
Type: boolean
An optional boolean value that lets you return field objects where the key is the field id.
This defaults to false, which returns field objects where the key is the field name.
Type: PerformUpsert
Optional. Enable/Disable upsert behavior. When upserting is enabled, the id property of records becomes optional.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
// Do something to obtain a AirtableRecord[] records containing records to replace the ones currently in the table.
// This AirtableRecord[] records has the same syntax as AirtableListRecordsResponse.Records returned by ListRecords().
Task<AirtableCreateUpdateReplaceMultipleRecordsResponse> task = airtableBase.ReplaceMultipleRecords(TABLE_NAME, records);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
}
else
{
errorMessage = "Unknown error";
}
// Report errorMessage
}
else
{
AirtableRecord[] records = response.Records;
// Do something with the replaced records
}
}
AirtableBase.ListComments(string, string, string, int?, CancellationToken))
List all comments for the record with a specific ID in a specific table as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableListCommentsResponse> ListComments(
string tableIdOrName,
string recordId,
string offset = null,
int? pageSize = null,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record is in.
Type: string
ID of the record to have all its comments listed.
string
A pointer to a specific comment. If specified, the returned comments will begin at the specified offset. An offset to the next set of comments will be provided by the API if the number of returned comments exceed the pageSize.
Type: int?
The number of records returned in each request. Must be less than or equal to 100.
Default is 100.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableListCommentsResponse> task = airtableBase.ListComments(YOUR_TABLE_NAME, recordId);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.CreateComment(string, string, string, CancellationToken)
Creates a comment on the record with a specific ID in a specific table as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateCommentResponse> CreateComment(
string tableIdOrName,
string recordId,
string commentText,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record is in.
Type: string
ID of the record to have a comment created on.
string
Text of the comment to be created.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableCreateUpdateCommentResponse> task = airtableBase.CreateComment(YOUR_TABLE_NAME, recordId, commentText);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.UpdateComment(string, string, string, CancellationToken))
Update a comment specified by its ID on the record with a specific ID in a specific table as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableCreateUpdateCommentResponse> UpdateComment(
string tableIdOrName,
string recordId,
string commentText,
string rowCommentId,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record is in.
Type: string
ID of the record to have its comment updated.
string
Update text of the comment.
string
Id of rowmComment to be updated.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableCreateUpdateCommentResponse> task = airtableBase.UpdateComment(YOUR_TABLE_NAME, recordId, commentText, rowCommentId);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.DeleteComment(string, string, string, CancellationToken))
Delete a comment specified by its ID on the record with a specific ID in a specific table as an asynchronous operation.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableDeleteCommentResponse> UpdateComment(
string tableIdOrName,
string recordId,
string rowCommentId,
Cancellation token = default(CancellationToken))
Type: string
Name of the table where the record is in.
Type: string
ID of the record to have its comment deleted.
string
Id of rowmComment to be delted.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableDeleteCommentResponse> task = airtableBase.DeleteComment(YOUR_TABLE_NAME, recordId, rowCommentId);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.CreateWebhook(WebhooksSpecification, string, CancellationToken))
Creates a new webhook in the specified base. Payloads may be generated and the notification URL (if given) will get a ping shortly after this completes.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableDeleteCommentResponse> CreateWebhook(
WebhooksSpecification spec,
string notificationUrl = null,
Cancellation token = default(CancellationToken))
Type: WebhooksSpecification
A object that describe the types of changes the webhook is interested in.
Type: string
An optional URL that can receive notification pings.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
WebhooksSpecification spec = CreateSpecForWebhook("tableData");
Task<AirtableCreateWebhookResponse> task = airtableBase.CreateWebhook(spec, YOUR_NOTIFICATION_URL);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
}
private WebhooksSpecification CreateSpecForWebhook(string dataTypes)
{
WebhooksSpecification spec = new WebhooksSpecification();
WebhooksOptions options = new WebhooksOptions ();
spec.Options = options;
WebhooksFilters filters = new WebhooksFilters ();
options.Filters = filters;
filters.RecordChangeScope = YOUR_TABLE_ID;
filters.DataTypes = new string[] { "tableData" /* , "tableFields"*/ };
WebhooksIncludes includes = new Includes();
includes.IncludePreviousCellValues = true;
includes.IncludeCellValuesInFieldIds = new string[] { "all" };
options.Includes = includes;
return spec;
}
AirtableBase.ListWebhooks(CancellationToken)
Lists all webhooks that are registered for a base, along with their statuses as an asynchronous operation. The base Id was provided when AirtableBase was constructed.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableListWebhooksResponse> ListWebhooks(Cancellation token = default(CancellationToken))
## Parameters
### token
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableListWebhooksResponse> task = airtableBase.ListWebhooks();
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.ListPayloads(CancellationToken)
Enumerate the update messages for a client to consume. Clients should call this after they receive a ping.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableListPayloadsResponse> ListPayloads(
string webhookId,
int? cursor = null,
int? limit = null,
Cancellation token = default(CancellationToken))
)
Type: string
Webhook ID
Type: int?
Transaction number of the payload to start listing from.
Type: int?
If given the limit parameter specifies the maximum number of payloads to return in the response.
A maximum of 50 payloads can be returned in a single request. A single payload can contain multiple updates.
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
/* Do something such as adding a record to a table and the Specification
* of a previously created Webhook (assuming its ID is WEBHOOK_ID) is for
* filtering "tableData".
*/
Task<AirtableListPayloadsResponse> task = airtableBase.ListPayloads(WEBHOOK_ID);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
var payloads = response.Payloads;
/* Do something with your WebhooksPayload[] payloads */
}
AirtableBase.EnableWebhookNotifications(CancellationToken)
Enables or disables notification pings for a webhook.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtabeEnableWebhookNotificationsResponse> EnableWebhookNotifications(
string webhookId,
bool enable,
Cancellation token = default(CancellationToken))
Type: string
Webhook ID
Type: bool
true for enabling, false for disabling
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtabeEnableWebhookNotificationsResponse> task = airtableBase.EnableWebhookNotifications(webhookId, true);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.RefreshWebhook(CancellationToken)
Extend the life of a webhook. The new expiration time will be 7 days after the refresh time. Note that this endpoint only applies to active webhooks with an expiration time. Creator level permissions are required in order to refresh a webhook.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtabeRefreshWebhookResponse> RefreshWebhook(
string webhookId,
Cancellation token = default(CancellationToken))
Type: string
Webhook ID
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtabeRefreshWebhookResponse> task = airtableBase.RefreshWebhook(webhookId);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
// Code making use of response.ExpirationTime goes here
}
AirtableBase.DeleteWebhook(CancellationToken)
Deletes a webhook. Creator level permissions are required in order to delete a webhook.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public async Task<AirtableDeleteWebhookResponse> DeleteWebhook(
string webhookId,
Cancellation token = default(CancellationToken))
Type: string
Webhook ID
Type: CancellationToken
An optional field for providing a means to cancel the operation.
The task object representing the asynchronous operation.
This operation will not block. The returned task object will complete once the entire response including content is read.
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using AirtableApiClient;
readonly string baseId = YOUR_BASE_ID;
readonly string appKey = YOUR_APP_KEY_OR_ACCESS_TOKEN;
using (AirtableBase airtableBase = new AirtableBase(appKeyOrAccessToken, baseId))
{
Task<AirtableDeleteWebhookResponse> task = airtableBase.DeleteWebhook(webhookId);
var response = await task;
if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
if (response.AirtableApiError is AirtableInvalidRequestException)
{
errorMessage += "\nDetailed error message: ";
errorMessage += response.AirtableApiError.DetailedErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
}
// Report errorMessage
}
}
AirtableBase.Dispose(CancellationToken)
Releases the unmanaged resources and disposes of the managed resources used by the class.
Namespace: AirtableApiClient
Assembly: AirtableApiClient.dll
public void Dispose()
IDisposable.Dispose()
- AirtableBase
- AirtableRecordList
-
AirtableRecordList
<T>
1. AirtableRecord<T>
- AirtableApiException
-
AirtableApiResponse
- AirtableListRecordsResponse
- AirtableListRecordsResponse
<T>
- AirtableRetrieveRecordResponse
- AirtableRetrieveRecordResponse
<T>
- AirtableCreateUpdateReplaceRecordResponse
- AirtableCreateUpdateReplaceMultipleRecordsResponse
- AirtableDeleteRecordResponse
- AirtableCreateUpdateCommentResponse
- AirtableListCommentsResponse
- AirtableDeleteCommentResponse
- AirtableListWebhooksResponse
- AirtableListPayloadsResponse
- AirtableCreateWebhookResponse
- AirtableDeleteWebhookResponse
- AirtabeEnableWebhookNotificationsResponse
- AirtabeRefreshWebhookResponse
- CommentList
- IdFields
- PerformUpsert
- UserIdAndScopes
- Webhooks
- PayloadList
- WebhooksNotification
[Airtable]: http://www.airtable.com