Skip to content

IsSuccessful always false when using RestResponse<T> #1675

@kingjan1999

Description

@kingjan1999

When using the latest RestSharp version, the property IsSuccessful of RestReponse<T> is always false. When using RestResponse, IsSuccessful is set to true whenever the request was successful.

Expected Behavior

The value of IsSuccessful does not depend on whether you use RestResponse<T> or RestResponse.

Actual Behavior

The value of IsSuccessful does depend on whether you use RestResponse<T> or RestResponse.

Steps to Reproduce the Problem

Code example:

    public class Program
    {
        class GithubRepo
        {
            public int Id { get; set; }
            public string Name { get; set; }
        }

        public static async Task Main(string[] args)
        {
            var restClient = new RestClient("https://api.github.com/");
            var request = new RestRequest("repos/RestSharp/RestSharp", Method.Get);
            var response1 = await restClient.ExecuteAsync<GithubRepo>(request);
            var response2 = await restClient.ExecuteAsync(request);
            
            Console.WriteLine(response1.IsSuccessful);
            Console.WriteLine(response2.IsSuccessful);            
        }
    }

This outputs:

False
True

Using RestSharp 106, the result is

True
True

Specifications

  • Version: 107.0.0.-preview.13
  • Platform: .NET Core 3.1 @ Ubuntu
  • Subsystem:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions