Skip to main content

I get this exception:

Exception thrown: ‘System.Net.Http.HttpRequestException’ in mscorlib.dll

An error occurred while sending the request. - System.Net.Http.HttpRequestException

The program ‘a10796] Test.vshost.exe’ has exited with code -1 (0xffffffff).




The code of Airtable.net in github is at link: GitHub - ngocnicholas/airtable.net: Airtable .NET API Client

The code I wrote for using of Airtable.net APIs:


private async void GetRecord(string id)

{

using (AirtableBase airtableBase = new AirtableBase(appKey, baseId))

{

Task task= airtableBase.RetrieveRecord(appTable, id);


            AirtableRetrieveRecordResponse response = null;
try
{
response = await task;
}
catch (System.Net.Http.HttpRequestException ex)
{
Console.WriteLine(ex.Message.ToString() + " - " + ex.GetType());
//throw;
}

if (!response.Success)
{
string errorMessage = null;
if (response.AirtableApiError is AirtableApiException)
{
errorMessage = response.AirtableApiError.ErrorMessage;
}
else
{
errorMessage = "Unknown error";
}
Console.WriteLine(errorMessage);
}
else
{
var record = response.Record;
// Do something with your retrieved record.
// Such as getting the attachmentList of the record if you
// know the Attachment field name
var attachmentList = response.Record.GetAttachmentField(id);
foreach (var attachmentField in attachmentList)
{
Console.WriteLine(attachmentField.ToString());
}
}
}
}



I catch exception at this line:

catch (System.Net.Http.HttpRequestException ex).

Why the trying to request to airtable database fails?

Be the first to reply!

Reply