Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am facing issue while consuming restful service POST method. It is showing Status code 0, but while am trying to give same request from POSTMAN rest client (A google chrome extension) it works fine. below is the code am using to post some data.
C#
var request = new RestRequest() { Method = Method.Post };
request.Timeout = 30000000;
request.AddBody(body);
var client = new RestClient(new RestClientOptions(url) { Authenticator = httpauth,MaxTimeout = 3000 });
RestResponse restResponse = client.Execute(request);

I am facing the below error message
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at RestSharp.RestClient.<ExecuteRequestAsync>d__3.MoveNext()
Could you please me to fix this issue.

What I have tried:

I have tried different ways like Timeout and other options also tried.
Posted
Updated 26-Nov-23 20:50pm
v4
Comments
Richard Deeming 21-Nov-23 3:58am    
You've provided a stack trace, but you forgot to provide the error message.
Ram349 21-Nov-23 6:52am    
Thanks Richard for respond to my post. I am getting the A task was canceled error message is getting.

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