Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,
I have to access one Rest API thorough ASP.NET c#
It is working fine through POSTMAN
But i am getting Internal server error while accessing thorough code
Can anyone please help me?
Here my code:-

What I have tried:

C#
var client = new RestClient("https://example.com/DataService/CustomerData/GetCustomerActivityDailySummary");
ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var certFile = Path.Combine(@"D:\myproject\", "certificate1.pfx");
X509Certificate2 certificate = new X509Certificate2(certFile, "12345678)");
client.ClientCertificates = new X509CertificateCollection() { certificate };
client.Proxy = new WebProxy();
var restrequest = new RestRequest(Method.POST);
restrequest.AddHeader("Cache-Control", "no-cache");
restrequest.AddHeader("Accept", "application/json");
restrequest.AddHeader("Content-Type", "application/json");
restrequest.AddParameter("here i have added the request parameter",ParameterType.RequestBody);
IRestResponse response = client.Execute(restrequest);
Posted
Updated 8-Mar-21 4:22am
v3
Comments
Richard MacCutchan 12-Aug-19 9:30am    
You need to check the server logs.
Richard Deeming 13-Aug-19 11:10am    
The request you're sending from your code does not match the request you're sending from Postman.

Use something like Fiddler[^] to capture both requests and compare them to find out what's different.

If you're still stuck, then contact the support team for the API you're trying to call.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900