Post here any issues you’re having with getting the tests working, or references not being set, or anything else that might make Lesson 6 unsuccessful for you. Let’s get you up and running with a passing check!
This has been great so far! But realized that the new version of Restsharp (107), has quite some breaking changes. So if you want to follow this course, you need to install an older version of restsharp (106 or older), or understand that the code need to be quite a bit different to get it working.
Wow thanks for sharing that @marco_s !
@sarahdeery or @mwinteringham can we get the requirements updated on the site?
I’ll start working on updating the course material but it’ll take a little while.
Again, thanks for bringing this up @marco_s !!!
@g33klady just let us know what we need to update and we can arrange it
Following on from @marco_s post regarding changes from version 106 to 107, it would be really handy if the material could be updated as I’d like to use the most up-to-date version.
The first change I stumbled across is the client and request setup, it looks like the client and resource name are now split between the RestClient and RestRequest as follows:
var client = new RestClient(“https://localhost:44367/”);
var request = new RestRequest(“api/Todo”, Method.Get);
The next issue is that IRestReponse no longer exists, nor does client.Execute. Looks like the whole model has been changed. I’ll try and work out what the new usage is and will post here if I can make sense of it. Of course, this is just the first hurdle and I’m not sure how much of the rest of the course will need updating. Any advice appreciated.
Updates are in progress! It’s a lot to update (9 lessons need updates to the recordings/demos), but I’m actively working on them now.
Thanks for keeping me honest folks!
In the meantime, you can install RestSharp 106.6.10 (downgrade in the Nuget Package Manager to that version from latest) and the lessons will work. You’ll at least be able to continue on and get the idea of what’s going on, knowing there will be some changes later but the fundamentals are still there.
Hope this helps!
Howdy! Just a note to let you all know that Hilary has updated the course material and it’s live on our site
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();
Thanks for this tip! There’s a popup that Visual Studio gives you for it so you can bypass it, but good to know there’s a solution for VS Code!