Skip to content

NullReferenceException for body parameters that don't have a name #1300

@stodolos

Description

@stodolos

Expected Behavior

I would not have to add a name, or the error message would be clearer that a parameter name was missing.

Actual Behavior

A NullReferenceException is thrown.

Steps to Reproduce the Problem

  1. Add a request body parameter without a name

This must be the issue in RestClient.ConfigureHttp (it's assuming the name is there):

var parameterExists =
                    request.Parameters.Any(p =>
                        p.Name.Equals(defaultParameter.Name, StringComparison.InvariantCultureIgnoreCase)
                        && p.Type == defaultParameter.Type);

Specifications

  • Version: 106.6.9.0
  • Platform: .NET Framework
  • Subsystem:

StackTrace

System.NullReferenceException: Object reference not set to an instance of an object. at RestSharp.RestClient.<>c__DisplayClass172_0.b__8(Parameter p) at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) at RestSharp.RestClient.ConfigureHttp(IRestRequest request) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action`2 callback, String httpMethod, Func`4 getWebRequest) at RestSharp.RestClient.ExecuteAsync(IRestRequest request, Action`2 callback, Method httpMethod)

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