Я пытаюсь отправить ключ и значения в URL-адрес API, но когда SendAsync выдает ошибку 500, и я проверяю ее на Почтальоне, и она работает нормально ... что я делаю неправильно?Я думаю, это ключевые значения, которые я создаю и отправляю на отправку IDK ... (Я новичок в этом (API)).
var token = await GetToken();
RequestModel requestModel = new RequestModel(requestViewModel);
string Baseurl = "https://example.api.com";
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(Baseurl);
client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", string.Format("Bearer {0}", token));
var request = new HttpRequestMessage(HttpMethod.Post, "/example.api/api/test/individual/get");
var keyValues = new List<KeyValuePair<string, string>>();
keyValues.Add(new KeyValuePair<string, string>("SolicitantData", null));
keyValues.Add(new KeyValuePair<string, string>("Name", requestViewModel.SolicitantDataView.Name));
keyValues.Add(new KeyValuePair<string, string>("MiddleInitial", requestViewModel.SolicitantDataView.MiddleInitial));
keyValues.Add(new KeyValuePair<string, string>("LastName", requestViewModel.SolicitantDataView.LastName));
keyValues.Add(new KeyValuePair<string, string>("LastName2", requestViewModel.SolicitantDataView.LastName2));
keyValues.Add(new KeyValuePair<string, string>("NickName", ""));
keyValues.Add(new KeyValuePair<string, string>("SSN", requestViewModel.SolicitantDataView.SSN));
keyValues.Add(new KeyValuePair<string, string>("BirthDate", requestViewModel.SolicitantDataView.BirthDate.ToString()));
keyValues.Add(new KeyValuePair<string, string>("EmailAddress", requestViewModel.SolicitantDataView.EmailAddress));
keyValues.Add(new KeyValuePair<string, string>("DriverLicense", ""));
keyValues.Add(new KeyValuePair<string, string>("DeathDate", ""));
keyValues.Add(new KeyValuePair<string, string>("Addresses", "[]"));
keyValues.Add(new KeyValuePair<string, string>("PhoneNumbers", "[]"));
keyValues.Add(new KeyValuePair<string, string>("TerminalId", requestViewModel.TerminalId.ToString()));
keyValues.Add(new KeyValuePair<string, string>("OGPATGNumber", ""));
keyValues.Add(new KeyValuePair<string, string>("OGPCorrelationID", ""));
keyValues.Add(new KeyValuePair<string, string>("Source", requestViewModel.Source));
keyValues.Add(new KeyValuePair<string, string>("UserId", ""));
keyValues.Add(new KeyValuePair<string, string>("IndividualId", ""));
keyValues.Add(new KeyValuePair<string, string>("SendByEmail", requestViewModel.SendByEmail.ToString()));
request.Content = new FormUrlEncodedContent(keyValues);
var response = await client.SendAsync(request); // <----- Code 500 here.
}
return View();
}