StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
Submit button code as followsprotected void btnsubmit_Click(object sender, EventArgs e)
{
string reqkeys = dist_Equp_Reqs.FirstOrDefault().Opa;
dist_Equp_Reqs.FirstOrDefault().Opa = string.Empty;
Dist_Equp_Response dist_Response = new Dist_Equp_Response();
dist_Response = httpHelper.PostAsync<Dist_Equp_Response, Dist_Equp_Req>(dist_Equp_Reqs.FirstOrDefault(), url).GetAwaiter().GetResult();
List<int> updateKeys = reqkeys.Split(',').Select(int.Parse).ToList();
string resulttype = "E";
string resultmsg = "";
string alertmsg = "Unable to Post in SAP ";
if (dist_Response != null && dist_Response.d != null && dist_Response.d.NavReturn != null && dist_Response.d.NavReturn.results != null)
{
foreach (EquipReturnNavresults r in dist_Response.d.NavReturn.results)
{
resulttype += "|" + r.Type;
resultmsg += "|" + r.Type + ":" + r.Message;
}
if (!string.IsNullOrEmpty(resultmsg))
{
resulttype.Remove(0, 1);
resultmsg.Remove(0, 1);
alertmsg = resultmsg;
}
}
foreach (int key in updateKeys)
{
SqlCommand cmd = new SqlCommand("UPDATE [transact].[transaction_item] SET Status = '" + resulttype + "',status_description = '" + resultmsg + "',posteddate = convert(varchar, getdate(), 103),username = '" + Request.Cookies["SpiderUserLoginName"].Value.ToString() + "' Where transaction_id=" + key.ToString(), con);
cmd.ExecuteNonQuery();
ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('" + alertmsg + "');", true);
}
}
public async Task<T> PostAsync<T, V>(V data, string url) where T : new() where V : new()
{
try
{
Logger log = new Logger();
log.WriteToErrorLog("Info", "Info", url, "", "");
Console.WriteLine(ToJSON(data));
log.WriteToErrorLog("Request", "Info", ToJSON(data), "", "");
var result = new T();
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls12
| SecurityProtocolType.Ssl3;
var client = new HttpClient();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = await client.PostAsJsonAsync(url, data).ConfigureAwait(false);
log.WriteToErrorLog("Responsecode", "Info", response.ToString(), "", "");
if (null != response && response.IsSuccessStatusCode)
{
var content = response.Content.ReadAsStringAsync().Result;
result = await Task.Run(() => JsonConvert.DeserializeObject<T>(content)).ConfigureAwait(false);
}
return result;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Logger log = new Logger();
log.WriteToErrorLog("Trasnaction Report Error in PostAsync", "EXCEPTION", ex.ToString(), "", "");
}
return default(T);
}
in the run mode i have gridview and select the gridview data using check box, when i click the submit button shows error in log file as follows
StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
in my above code what is the mistake. what changes i have to made in my above code.