Home » c# » C# REST API communication-Exceptionshub

C# REST API communication-Exceptionshub

Posted by: admin February 24, 2020 Leave a comment

Questions:

I’ve a C#/WPF application that connects to a Java REST API. Job url is: “https://myDevServer:7655/myTestJob“. The method on the server returns a string called “success”.

When I hit this url using POSTMAN software on my machine, I get a “success” message in the response back from the java API, as expected.

But when I try to programmatically send request through C# app running on my machine, I get a message saying:
“The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.”
My C# code :

        var restClient = new MyRestClient("https://myDevServer:7655");
        var request = RequestFactory.CreatePOST("/myTestJob");
        var response = (RestResponse<List<string>>)restClient.Execute<List<string>>(request);
        restClient.ValidateResponse(response);

Am I missing something here?

Thanks.

How to&Answers: