Skip to content
ngocnicholas edited this page Mar 30, 2017 · 5 revisions

Welcome to the AirtableApiClient wiki!

AirtableApiClient.dll Dynamic Link Library is the C# interface of Airtable API client.

It provides the namespace AritableApiClient which make available many classes to the users. The AirtableBase class is by far the most important class of AirtableApiClient.

AirtableBase Class

Implements all the capabilities of Airtable API client.

Namespace: AirtableApiClient

Assembly: AirtableApiClient.dll

Syntax

public class AirtableBase : IDisposable

The AirtableBase type exposes the following members.

Constructor

Name Description
public AirtableBase(string, baseId) initializes a new instance of AirtableBase with a specific API key and a specific Base ID

Methods

Name Description
ListRecords(string, string, IEnumerable, string int?, int?, IEnumerable, string) Get a list pf records in a specific table as an asynchronous operation.
RetrieveRecord(string, string) Retrieve a record with a specific id from a specific table as an asynchronous operation.
CreateRecord(string, Fields, bool) Create a record in a specific table using information provided by caller as an asynchronous operation.
UpdateRecord(string, Fields, string, bool) Update a record with a specific ID in a specific table as an asynchronous operation.
ReplaceRecord(string, Fields, string, bool) Replace a record with a specific ID in a specific table as an asynchronous operation.
DeleteRecord(string, string) Delete a record with a specific ID in a specific table as an asynchronous operation.
Dispose() Releases the unmanaged resources and disposes of the managed resources used by the class

ListRecords Method

Airtable.ListRecords(string, string, IEnumerable, string, int?, int?, IEnumerable, string)

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

Syntax

        public async Task<AirtableListRecordsResponse> ListRecords(
            string tableName,
            string offset = null,
            IEnumerable<string> fields = null,
            string filterByFormula = null,
            int? maxRecords = null,
            int? pageSize = null,
            IEnumerable<Sort> sort = null,
            string view = null)

Parameters

tableName

Type: string   
Name of the table of which the records to be retrieved from

offset

Type: string
offset into the table where the record listing starts

fields

Type: Fields

filterByFormula

Type: string

maxRecords

Type: int

pageSize

Type int

sort

Type: Sort

view

Type: string

Return Value

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned task object will complete once the entire response including content is read.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AirtableApiClient;
        readonly string baseId = YOUR_BASE_ID;
        readonly string appKey = YOUR_APP_KEY;  

        string offset = null;
        string errorMessage = null;
        var records = new List<AirtableRecord>();

        try
        {
           using (AirtableBase airtableBase = new AirtableBase(appKey, baseId))
           {
               //
               // 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, 
                       fieldsArray, 
                       filterByFormula, 
                       maxRecords, 
                       pageSize, 
                       sort, 
                       view);

                    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;
                        break;
                    }
                    else
                    {
                        errorMessage = "Unknown error";
                        break;
                    }
                } while (offset != null);
            }
        }

        catch (Exception e)
        {
            errorMessage = e.Message;
        }

        if (!string.IsNullOrEmpty(errorMessage))
        {
            // Error reporting
        }
        else
        {
            // Do something with the retrieved 'records' and the 'offset'
            // for the next page of the record list.
        } 
    }


RetrieveRecord Method

Airtable.RetrieveRecord(string, string)

Retrieve a record with a specific ID from a specific table as an asynchronous operation.

Namespace: AirtableApiClient

Assembly: AirtableApiClient.dll

Syntax

        public async Task<AirtableRetrieveRecordResponse> RetrieveRecord(
            string tableName,
            string id)

Parameters

tableName

Type: string   
Name of the table of which the record to be retrieved from

id

Type: string
ID of the record to be retrieved.

Return Value

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned task object will complete once the entire response including content is read.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AirtableApiClient;

        readonly string baseId = YOUR_BASE_ID;
        readonly string appKey = YOUR_APP_KEY;  

        using (AirtableBase airtableBase = new AirtableBase(appKey, 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);

            }
        }


CreateRecord Method

AirtableBase.CreateRecord(string, Fields, bool)

Create a record in a specific table using provided information as an asynchronous operation.

Namespace: AirtableApiClient

Assembly: AirtableApiClient.dll

Syntax

        public async Task<AirtableCreateUpdateReplaceRecordResponse> CreateRecord(
            string tableName,
            Fields fields,
            bool typecast = true)

Parameters

tableName

Type: string   
Name of the table where the record will be created

fields

Type: Fields

typeCast

Type: bool
Enable/Disable automatic data conversion. Default to 'true'.

Return Value

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned task object will complete once the entire response including content is read.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AirtableApiClient;

        readonly string baseId = YOUR_BASE_ID;
        readonly string appKey = YOUR_APP_KEY;  

        using (AirtableBase airtableBase = new AirtableBase(appKey, 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(tableName, 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.
            }
        }


UpdateRecord Method

AirtableBase.UpdateRecord(string, Fields, string, bool)

Update a record in a specific table using provided information as an asynchronous operation.

Namespace: AirtableApiClient

Assembly: AirtableApiClient.dll

Syntax

        public async Task<AirtableCreateUpdateReplaceRecordResponse> UpdateRecord(
            string tableName,
            Fields fields,
            string id,
            bool typeCast = true)

Parameters

tableName

Type: string   
Name of the table where the record will be updated

fields

Type: Fields

id

ID of the record to be updated.

typeCast

Type: bool
Enable/Disable automatic data conversion. Default to 'true'.

Return Value

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned task object will complete once the entire response including content is read.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AirtableApiClient;

        readonly string baseId = YOUR_BASE_ID;
        readonly string appKey = YOUR_APP_KEY;  

        using (AirtableBase airtableBase = new AirtableBase(appKey, baseId))
        {
            var fields = new Fields();
            fields.AddField("Name", "Pablo Picasso Updated");
            fields.AddField("On Display?", true);

            Task<AirtableCreateUpdateReplaceRecordResponse> task = airtableBase.UpdateRecord(tableName, 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.
            }
        }


ReplaceRecord Method

AirtableBase.ReplaceRecord(string, Fields, string, bool)

Replace a record with a specific ID in a specific table using provided information as an asynchronous operation.

Namespace: AirtableApiClient

Assembly: AirtableApiClient.dll

Syntax

        public async Task<AirtableCreateUpdateReplaceRecordResponse> ReplaceRecord(
            string tableName,
            Fields fields,
            string id,
            bool typeCast = true)

Parameters

tableName

Type: string   
Name of the table where the record will be replaced with information provided by caller.

fields

Type: Fields

id

ID of the record to be replaced.

typeCast

Type: bool
Enable/Disable automatic data conversion. Default to 'true'.

Return Value

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned task object will complete once the entire response including content is read.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AirtableApiClient;

        readonly string baseId = YOUR_BASE_ID;
        readonly string appKey = YOUR_APP_KEY;  

        using (AirtableBase airtableBase = new AirtableBase(appKey, 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(tableName, 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.
            }
        }


DeleteRecord Method

AirtableBase.DeleteRecord(string, string)

Delete a record with a specific ID in a specific table as an asynchronous operation.

Namespace: AirtableApiClient

Assembly: AirtableApiClient.dll

Syntax

        public async Task<AirtableDeleteRecordResponse> DeleteRecord(
            string tableName,
            string id)

Parameters

tableName

Type: string   
Name of the table where the record will be deleted

id

ID of the record to be deleted.

Return Value

The task object representing the asynchronous operation.

Remarks

This operation will not block. The returned task object will complete once the entire response including content is read.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AirtableApiClient;

        readonly string baseId = YOUR_BASE_ID;
        readonly string appKey = YOUR_APP_KEY;  

        using (AirtableBase airtableBase = new AirtableBase(appKey, 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;
                }
                else
                {
                    errorMessage = "Unknown error";
                }
                // Report errorMessage
            }
        }


Dispose Method

AirtableBase.Dispose()

Releases the unmanaged resources and disposes of the managed resources used by the class.

Namespace: AirtableApiClient

Assembly: AirtableApiClient.dll

Syntax

        public void Dispose()

Implements

IDisposable.Dispose()

  1. AirtableBase
  2. AirtableRecordList
    1. AirtableRecord
      1. AirtableAttachment
        1. Thumbnails
          1. Thumbnail
      2. Fields
        1. Sort
          1. SortDirection
  3. AirtableRecordList<T>
    1. AirtableRecord<T>
  4. AirtableUpSertRecordList
  5. AirtableUpSertRecordList<T>
  6. AirtableApiException
    1. AirtableUnrecognizedException
    2. AirtableBadRequestException
    3. AirtableUnauthorizedException
    4. AirtablePaymentRequiredException
    5. AirtableForbiddenException
    6. AirtableNotFoundException
    7. AirtableRequestEntityTooLargeException
    8. AirtableInvalidRequestException
    9. AirtableTooManyRequestsException
  7. AirtableApiResponse
    1. AirtableGetUserIdAndScopesResponse
    2. AirtableListRecordsResponse
    3. AirtableListRecordsResponse<T>
    4. AirtableRetrieveRecordResponse
    5. AirtableRetrieveRecordResponse<T>
    6. AirtableCreateUpdateReplaceRecordResponse
    7. AirtableCreateReplaceRecordResponse<T>
    8. AirtableCreateReplaceMultipleRecordsResponse<T>
    9. AirtableCreateUpdateReplaceMultipleRecordsResponse
    10. AirtableDeleteRecordResponse
    11. AirtableCreateUpdateCommentResponse
    12. AirtableListCommentsResponse
    13. AirtableDeleteCommentResponse
    14. AirtableListWebhooksResponse
    15. AirtableListPayloadsResponse
    16. AirtableCreateWebhookResponse
      1. CreateWebhookResponse
    17. AirtableDeleteWebhookResponse
    18. AirtabeEnableWebhookNotificationsResponse
    19. AirtabeRefreshWebhookResponse
    20. AirtableListBasesResponse
    21. AirtableGetBaseSchemaResponse
    22. AirtableCreateBaseResponse
  8. CommentList
    1. Comment
      1. Author
      2. Mentioned
        1. MentionedEntity
  9. IdFields
  10. PerformUpsert
  11. UserIdAndScopes
  12. Webhooks
    1. Webhook
      1. WebhooksSpecification
        1. WebhooksOptions
          1. WebhooksFilters
          2. WebhooksIncludes
  13. PayloadList
    1. WebhooksPayload
  14. WebhooksNotification
  15. TableModelList
    1. TableModel
      1. DateDependencySettings
      2. ViewModel
      3. FieldModel
      4. FieldModel<TModelOptions>
        1. aitextfieldmodel-and-aitextmodeloptions
        2. AttachmentFieldModel-and-AttachmentModelOptions
        3. AutoNumberFieldModel
        4. BarcodeFieldModel
        5. ButtonFieldModel
        6. CheckboxFieldModel
          1. CheckboxModelOptions
        7. CollaboratorFieldModel
        8. CountFieldModel-and-CountModelOptions
        9. CreatedByFieldModel
        10. CreatedTimeFieldModel-and-CreatedTimeModelOptions
        11. CurrencyFieldModel
          1. CurrencyModelOptions
        12. DateFieldModel
          1. DateModelOptions
            1. DateFormat
        13. DateTimeFieldModel
          1. DateTimeModelOptions
            1. TimeFormat
        14. DurationFieldModel
          1. DurationModelOptions
        15. EmailFieldModel
        16. FormulaFieldModel--and-FormulaModelOptions
        17. LastModifiedByFieldModel
        18. LastModifiedTimeFieldModel-and-LastModifiedTimeModelOptions
        19. LinkToAnotherRecordFieldModel-and-LinkToAnotherRecordModelOptions
        20. LongTextFieldModel
        21. LookupFieldModel-and-LookupModelOptions
        22. MultipleCollaboratorFieldModel
        23. MultipleSelectFieldModel-and-MultipleSelectdModelOptions
          1. ChoiceModelOptions-and-ChoiceConfigOptions
        24. NumberFieldModel-and-NumberModelOptions
          1. PrecisionModelOptions
        25. PercentFieldModel-and-PercentModelOptions)
        26. PhoneFieldModel
        27. RatingFieldModel
          1. RatingModelOptions
        28. RichTextFieldModel
        29. RollupFieldModel-and-RollupModelOptions
        30. SingleLineTextFieldModel
        31. SingleSelectFieldModel-and-SingleSelectdModelOptions
        32. SyncSourceFieldModel-and-SyncSourceModelOptions
        33. UrlFieldModel
        34. UnknownFieldModel
    2. FieldModelExtensions
      1. TryGetOptions
      2. RequireOptions
  16. TableConfig
    1. IFieldConfig
      1. Field
      2. FieldConfig
        1. AttachmentFieldConfig
        2. BarcodeFieldConfig
        3. CheckboxFieldConfig
          1. CheckboxConfigOptions
        4. CollaboratorFieldConfig
        5. CurrencyFieldConfig
          1. CurrencyConfigOptions
        6. DateFieldConfig
          1. DateConfigOptions
        7. DateTimeFieldConfig
          1. DateTimeConfigOptions
        8. DurationFieldConfig
          1. DurationConfigOptions
        9. EmailFieldConfig
        10. LinkToAnotherRecordFieldConfig-and-LinkToAnotherRecordConfigOptions
        11. LongTextFieldConfig
        12. MultipleCollaboratorFieldConfig
        13. MultipleSelectFieldConfig-and-MultipleSelectdConfigOptions
          1. ChoiceModelOptions-and-ChoiceConfigOptions
        14. NumberFieldConfig-and-NumberConfigOptions
          1. PrecisionConfigOptions
        15. PercentFieldConfig-and-PercentConfigOptions
        16. PhoneFieldConfig
        17. RatingFieldConfig
          1. RatingConfigOptions
        18. RichTextFieldConfig
        19. SingleLineTextFieldConfig
        20. SingleSelectFieldConfig-and-SingleSelectdConfigOptions
        21. UrlFieldConfig


[Airtable]: http://www.airtable.com

Clone this wiki locally