我很难从我的测试 .net 应用程序向 airtable 添加记录。我能够很好地读取数据,但我不确定我是否正确格式化数据或没有在标题中添加内容。这是一个例子:
Dim wHeader As WebHeaderCollection = New WebHeaderCollection()
wHeader.Clear()
wHeader.Add("Authorization: Bearer keynNkH2CywXXXXX")
Dim sUrl As String = "https://api.airtable.com/v0/appGajjD5tTMmyCC5/Logs"
Dim wRequest As HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create(sUrl), HttpWebRequest)
wRequest.ContentType = "application/json" ' I don't know what your content type is
wRequest.Headers = wHeader
wRequest.Method = "POST"
wRequest.Accept = "*/*"
Dim myData = "{""fields"": {""AppName"": ""test2"", ""Action"": ""hlkj"", ""User"": ""lhkjnjn""}}"
wRequest.GetRequestStream.Write(System.Text.Encoding.UTF8.GetBytes(myData), 0, System.Text.Encoding.UTF8.GetBytes(myData).Count)
Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)
Dim sResponse As String = ""
Using srRead As New StreamReader(wResponse.GetResponseStream())
sResponse = srRead.ReadToEnd()
End Using
MessageBox.Show(sResponse)
我不断收到的错误是“422 Unprocessable Entity”。