Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

453
Views
Error CS0246 The type or namespace name 'JsonDeserializer' could not be found (RestSharp v107)

I get an error (after update RestSharp - v107) on the following line:

var contacts = new JsonDeserializer().Deserialize<List<Contact>>(response);

Error CS0246 The type or namespace name 'JsonDeserializer' could not be found (are you missing a using directive or an assembly reference?)

using NUnit.Framework;
using RestSharp;
using System.Text.Json;
using System;
using System.Collections.Generic;
using System.Net;

namespace ContactBook.ApiTests
{
public class ContactBookApiTests
{
    const string ApiBaseUrl = "URl/api";
    RestClient client;

    [SetUp]
    public void Setup()
    {
        this.client = new RestClient(ApiBaseUrl);
    }

    [Test]
    public void Test_ListContacts_CheckForSteveJobs()
    {
        // Arrange
        var request = new RestRequest("/contacts", Method.Get);

        // Act
        var response = this.client.ExecuteAsync(request);

        // Assert
        Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK));
        var contacts = new JsonDeserializer().Deserialize<List<Contact>>(response);
        Assert.That(contacts.Count, Is.GreaterThan(0));
        var firstContact = contacts[0];
        Assert.That(firstContact.firstName, Is.EqualTo("Steve"));
        Assert.That(firstContact.lastName, Is.EqualTo("Jobs"));
    }
    }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

try this

 var response = this.client.ExecuteAsync(request).Result;

  //or better

var response = this.client.Execute(request);
....

 var contacts = JsonSerializer.Deserialize<List<Contact>>(response.Content);
over 4 years ago · Santiago Trujillo Report

0

var response = this.client.ExecuteAsync(request);

As the name suggests, this function returns Task<RestResponse>. You need to await the call.

There's also no need to explicitly deserialize the response, RestSharp will do it for you.

public async Task Test_ListContacts_CheckForSteveJobs() {
    var request = new RestRequest("/contacts", Method.Get);
    var response = await client.ExecuteAsync<Contact[]>(request);
    var contacts = response.Data;

    // Assert
    Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK));
    Assert.That(contacts.Count, Is.GreaterThan(0));
    var firstContact = contacts[0];
    Assert.That(firstContact.firstName, Is.EqualTo("Steve"));
    Assert.That(firstContact.lastName, Is.EqualTo("Jobs"));
}
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!