我正在使用RESTful调用socrata数据门户来获取数据。
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(WebConfigurationManager.AppSettings["APIEndPointHost"]);
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
string userName = WebConfigurationManager.AppSettings["UserName"];
string password = WebConfigurationManager.AppSettings["PassWord"];
string credentials = userName + ":" + password;
var byteArray = Encoding.ASCII.GetBytes(credentials);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
client.DefaultRequestHeaders.Add("X-App-Token", WebConfigurationManager.AppSettings["AppToken"]);
HttpResponseMessage response = new HttpResponseMessage();
string searchCondition = "resource/xxxx-xxxx.json?$where=column1='something'AND column2='something';
response = client.GetAsync(searchCondition).Result;
问题在于,有时候' searchCondition'可以说非常大,超过5000个字符,然后在执行时会出现以下错误。
发送请求时发生错误。
服务器提交了协议违规。节= ResponseStatusLine
这是因为我发送了一个大的requestUri,还是这与socrata限制搜索条件限制有关?