ngocnicholas / airtable.net

Airtable .NET API Client
MIT License
141 stars 34 forks source link

Fields with a whitespace in the name aren't pulled through #82

Closed laurent-afs closed 7 months ago

laurent-afs commented 9 months ago

Hi,

We've been using this package for a little while now without any issues, and had to upgrade recently from 1.1.4 to 1.4.0 (the main purpose of the upgrade was being able to use an access token instead of a deprecated API key).

The upgrade seems to have broken some part of the functionality - we have a DTO representing our records in Airtable for mapping purposes, with the fields defined as such:

[JsonProperty("Country Code")]
public string CountryCode { get; set; } = string.Empty;

Most fields are pulled through just fine, only the ones with a whitespace in the name aren't. Is there a work around for this? If that helps this is how we're listing records using AirtableBase. In the following example T is the DTO mentioned above.

var response = await _airtableBase.ListRecords<T>(tableName, offset);
var records = response.Records.Select(AirtableRecordWrapper<T>.From);

Thank you!

laurent-afs commented 9 months ago

For what it's worth, we had to downgrade to 1.1.5 for this to work again. Anything including and above 1.1.6 introduces that breaking change.

ngocnicholas commented 9 months ago

1.1.6 was released when I replaced Newtonsoft.json with System.Text.Json. 6.0.2 [JsonProperty("Country Code")] should be [JsonPropertyName("Country Code")]

I cannot duplicate your problem. My test base has field names with spaces in them such as "Country Code". I wrapped my class in a class name Artist and call: public class Artist { public string Name { get; set; } public List Attachments { get; set; } public string Bio { get; set; }

        [JsonPropertyName("On Display?")]
        public bool OnDisplay { get; set; }

        public List<string> Collection { get; set; }
        public List<string> Genre { get; set; }

        [JsonPropertyName("Country Code")]
        public string CountryCode{ get; set; }
    }
        Task<AirtableListRecordsResponse<Artist>> task = airtableBase.ListRecords<Artist>(TABLE_NAME);
        var response = await task;
        var records = response.Records.ToList();
        Artist AlHeld = records[0].Fields;
        Console.WriteLine(AlHeld.CountryCode);   // The output looks correct
ngocnicholas commented 7 months ago

No more replies from user. Problem considered solved.