private async Task <(string ResponseBody, AirtableApiException Error)> ListRecordsInternal( string tableName, string offset, IEnumerable <string> fields, string filterByFormula, int?maxRecords, int?pageSize, IEnumerable <Sort> sort, string view) { if (string.IsNullOrEmpty(tableName)) { throw new ArgumentException("Table Name cannot be null", "tableName"); } var uri = BuildUriForListRecords(tableName, offset, fields, filterByFormula, maxRecords, pageSize, sort, view); var request = new HttpRequestMessage(HttpMethod.Get, uri); var response = await httpClientWithRetries.SendAsync(request); AirtableApiException error = await CheckForAirtableException(response); if (error != null) { return(null, error); } var responseBody = await response.Content.ReadAsStringAsync(); return(responseBody, null); }
//---------------------------------------------------------------------------- // // AirtableBase.RetrieveRecord // // Called to retrieve a record with the specified id from the specified table. // //---------------------------------------------------------------------------- public async Task <AirtableRetrieveRecordResponse> RetrieveRecord( string tableName, string id) { if (string.IsNullOrEmpty(tableName)) { throw new ArgumentException("Table Name cannot be null", "tableName"); } if (string.IsNullOrEmpty(id)) { throw new ArgumentException("Record ID cannot be null", "id"); } string uriStr = AIRTABLE_API_URL + BaseId + "/" + tableName + "/" + id; var request = new HttpRequestMessage(HttpMethod.Get, uriStr); var response = await httpClientWithRetries.SendAsync(request); AirtableApiException error = await CheckForAirtableException(response); if (error != null) { return(new AirtableRetrieveRecordResponse(error)); } var responseBody = await response.Content.ReadAsStringAsync(); var airtableRecord = JsonConvert.DeserializeObject <AirtableRecord>(responseBody); return(new AirtableRetrieveRecordResponse(airtableRecord)); }
//---------------------------------------------------------------------------- // // AirtableBase.ListRecords // // Called to get a list of records in the table specified by 'tableName' // //---------------------------------------------------------------------------- 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) { if (string.IsNullOrEmpty(tableName)) { throw new ArgumentException("Table Name cannot be null", "tableName"); } AirtableRecordList recordList = null; var uri = BuildUriForListRecords(tableName, offset, fields, filterByFormula, maxRecords, pageSize, sort, view); var request = new HttpRequestMessage(HttpMethod.Get, uri); var response = await httpClientWithRetries.SendAsync(request); AirtableApiException error = await CheckForAirtableException(response); if (error != null) { return(new AirtableListRecordsResponse(error)); } var responseBody = await response.Content.ReadAsStringAsync(); recordList = JsonConvert.DeserializeObject <AirtableRecordList>(responseBody); return(new AirtableListRecordsResponse(recordList)); }