Lesson 6 - Troubleshooting

Still working with VS Code. I got the first check to pass.

To set up the test project:

dotnet new classlib -o ApiChecks
dotnet sln add ApiChecks/ApiChecks.csproj

You need to install the same dependencies as Hilary did:

dotnet add package Nunit -v 3.13.3

and the other dependencies in the same way. I’ve got RestSharp 107.3.0.

I had some trouble because RestSharp did not want to execute the request because there is no trusted certificate. Creating a self-signed certificate alone did not help, the certificate must have a root certificate and the root certificate must be in the list of trusted certificates (I guess it’s the operating system that keeps a list of trusted certificates).
After struggling for a while, I just decided to ignore certificate errors.

// Arrange
var options = new RestClientOptions("https://localhost:5001/api/Todo"){
  RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true
};
var client = new RestClient(options);
var request = new RestRequest();
1 Like