Skip to content

ListRecords

ngocnicholas edited this page Mar 30, 2017 · 1 revision

AirtableBase.ListRecords Method(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.
        } 
    }

  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