How to send multiple records to Airtable via C# REST API calls

I’m still learning about working with APIs and JSON data in C#. I managed to get single record creation working with Airtable’s API, but now I need help sending multiple records at once.

Here’s my current working code for single records:

public static async Task SendSingleRecord()
{
    using (var client = new HttpClient())
    {
        using (var requestMsg = new HttpRequestMessage(new HttpMethod("POST"), "https://api.airtable.com/v0/MYAPPID/Podcasts"))
        {
            requestMsg.Headers.TryAddWithoutValidation("Authorization", "Bearer MYTOKEN");
            requestMsg.Content = new StringContent("{\"records\": [{  \"fields\": {    \"FeedURL\": \"https://feeds.example.com/rss/feed.xml\"  }}]}");
            requestMsg.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
            var result = await client.SendAsync(requestMsg);
        }
    }
}

I created these models to handle bulk data:

using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace PodcastManager
{
    public class BulkDataModel
    {
        public class DataFields
        {
            [JsonPropertyName("FeedURL")]
            [JsonInclude]
            public string FeedURL { get; set; }
        }

        public class DataRecord
        {
            [JsonPropertyName("fields")]
            [JsonInclude]
            public DataFields fields { get; set; }
        }

        public class RootObject
        {
            [JsonPropertyName("records")]
            [JsonInclude]
            public List<DataRecord> records { get; set; }
        }
    }
}

The JSON structure I’m trying to create looks like this:

{
  "records": [
    {
      "id": "rec123ABC",
      "fields": {
        "FeedURL": "https://feeds.example.com/podcast1/rss.xml"
      }
    },
    {
      "id": "rec456DEF", 
      "fields": {
        "FeedURL": "https://feeds.example.com/podcast2/rss.xml"
      }
    }
  ]
}

I’m stuck on how to populate my model from a DataGridView or List and serialize it properly for the API request. Any guidance would be helpful.

I’ve done something similar with Airtable before. Your model structure looks good, but you’re missing the ID property in your DataRecord class if you need it for updates. For creating new records, just omit the ID field.

Here’s how I usually populate the model from a collection:

public static async Task SendMultipleRecords(List feedUrls)
{
var rootObject = new BulkDataModel.RootObject
{
records = feedUrls.Select(url => new BulkDataModel.DataRecord
{
fields = new BulkDataModel.DataFields { FeedURL = url }
}).ToList()
};

var json = JsonSerializer.Serialize(rootObject);

using (var client = new HttpClient())
{
    using (var requestMsg = new HttpRequestMessage(HttpMethod.Post, "https://api.airtable.com/v0/MYAPPID/Podcasts"))
    {
        requestMsg.Headers.TryAddWithoutValidation("Authorization", "Bearer MYTOKEN");
        requestMsg.Content = new StringContent(json, Encoding.UTF8, "application/json");
        var result = await client.SendAsync(requestMsg);
    }
}

}

Just remember Airtable limits bulk operations to 10 records per request, so you’ll need to batch larger collections.

Had this exact problem last year migrating podcast data. The other answers are solid, but here’s what saved me tons of headaches.

For pulling from a DataGridView, try this:

public static async Task SendFromDataGridView(DataGridView dgv)
{
    var records = new List<BulkDataModel.DataRecord>();
    
    foreach (DataGridViewRow row in dgv.Rows)
    {
        if (row.Cells["FeedURLColumn"].Value != null)
        {
            records.Add(new BulkDataModel.DataRecord
            {
                fields = new BulkDataModel.DataFields 
                { 
                    FeedURL = row.Cells["FeedURLColumn"].Value.ToString() 
                }
            });
        }
    }
    
    // Batch into groups of 10
    for (int i = 0; i < records.Count; i += 10)
    {
        var batch = records.Skip(i).Take(10).ToList();
        var payload = new BulkDataModel.RootObject { records = batch };
        
        var json = JsonSerializer.Serialize(payload);
        // Your HTTP call here
    }
}

Biggest lesson: always validate your data first. Empty cells will kill your entire batch.

This tutorial breaks down the Airtable API really well:

Also throw in some retry logic for failed batches. Airtable gets weird with rate limits.

your model looks good, but watch out for the response handling. airtable sometimes returns partial success when some records fail - caught me off guard before. always check the status code and parse error messages from the response body so you know what went wrong.