Your C# code is sending raw CustomerData but Airtable needs it wrapped properly. You’re missing the records structure and the fields nesting.
I hit this exact same issue 2 years ago when building an integration for our customer management system. The JSON structure has to match exactly what Airtable expects.
Try this instead:
var payload = new
{
records = new[]
{
new
{
fields = new
{
UserName = data.UserName,
Avatar = data.Avatar
}
}
}
};
string jsonData = JsonConvert.SerializeObject(payload);
StringContent requestContent = new StringContent(jsonData, Encoding.UTF8, "application/json");
Also check your field names in Airtable. In your Postman response I see “UserId” but your C# class doesn’t have that field. Make sure the field names match exactly what you have in your Airtable base.
If you’re still getting 422 errors after this, check out this video that covers the most common causes:
One more thing - always log the response body when you get errors. It usually tells you exactly what’s wrong:
if (!result.IsSuccessStatusCode)
{
var errorContent = await result.Content.ReadAsStringAsync();
Debug.WriteLine($"Error: {result.StatusCode} - {errorContent}");
}
The 422 error likely stems from the way you’re structuring your JSON payload. Airtable expects the data to be wrapped in a “records” array and nested under “fields”. So you need to adjust your serialization to match this requirement. Additionally, ensure that you set the Content-Type header of your request to “application/json” with: requestContent.Headers.ContentType = new MediaTypeHeaderValue(“application/json”);. I experienced a similar issue previously and found that it was essential to adhere closely to the expected JSON format.