Hi Experts,
I am working on premise system in integration with LMS system.
we have to send prospects from our system to LMS system, before sending we have to check Outlet code based on that we have to send the prospect.
Checking means they provide the API where we are post the outlet code if it is existed in there list than we have send the prospect.
For Outlet code check I have written below method
in the method when execution reaching this line of code “var response = await client.SendAsync(request);” it is automatically closing the debugger and plugin Registration tool. Without catching any exception.
“DealerRequest” is class through it’s variable I am passing Outlet code.
public async Task checkProspect(DealerRequest dealerRequest, ITracingService itracingservice)
{
DealerResponse dealerresponse = new DealerResponse();
string TaskResponse = string.Empty;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "");
request.Headers.Add("accept", "application/json");
request.Headers.Add("client_id", "");
request.Headers.Add("client_key", "");
// Microsoft dll to convert object into json, don't use Newtonsoft.Json in on-premise
string json;
using (var ms = new MemoryStream())
{
var js = new DataContractJsonSerializer(typeof(DealerRequest));
js.WriteObject(ms, dealerrequest);
ms.Position = 0;
using (var sr = new StreamReader(ms))
{
json = sr.ReadToEnd();
}
}
var content = new StringContent(json, Encoding.UTF8, "application/json");
string responseContent = string.Empty;
request.Content = content;
itracingservice.Trace("Content :" + content);
try
{
var response = await client.SendAsync(request);
itracingservice.Trace("response :" + response);
if (response.IsSuccessStatusCode)
{
responseContent = await response.Content.ReadAsStringAsync();
itracingservice.Trace("Response Content: " + responseContent);
// var ser = new DataContractJsonSerializer(typeof(ProspectResponse));
Boolean check = responseContent.Contains("true");
dealerresponse = Utility.ReadToObject(responseContent);
itracingservice.Trace("dealerresponse: " + dealerresponse);
TaskResponse = dealerresponse.data;
itracingservice.Trace("TaskResponse :" + TaskResponse);
}
else
{
responseContent = await response.Content.ReadAsStringAsync();
itracingservice.Trace("responsecontent:" + responseContent);
return (responseContent);
}
}
catch (Exception ex)
{
TaskResponse = ex.ToString();
itracingservice.Trace("TaskResponse :" + TaskResponse);
}
return TaskResponse;
}
Kindly guide me
Thankyou in Advance.