I built a rest API that is used to send SMS messages and emails.I make an API call and get the following error:
"The underlying connection was closed: An unexpected error occurred on a receive."}
"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."
This is my code:
try{ var _client = new RestClient("https://xxxx:5000/test/api"); RestRequest request = new RestRequest("send-sms", Method.Post) { RequestFormat = DataFormat.Json }; request.AddJsonBody(new { MessageText = smsMessage.Body, SenderName = smsMessage.SenderName, RecipientPhone = smsMessage.To }); var response = _client.Execute(request); return response.IsSuccessful;}catch (Exception ex){ ExceptionHelper.OnlyWriteException(ex); return false;}
It doesn't work only from this project, from curl and another empty project it does work.
What could be the reason it failed?