Skip to content

It's impossible to add .Header() to certain types of requests #60

@nfidirko

Description

@nfidirko

Description

For certain types of requests (e.g. deleting a payment source), when you're trying to add a header via .Header() an exception is thrown.

Affected versions

  • 3.8.0
  • 3.9.0

(Haven't tests earlier version)

Code to reproduce the error

var request = ChargeBee.Models.PaymentSource.Delete("test");
request.Header("test", "test");

Exception

Unhandled exception. System.InvalidCastException: Object must implement IConvertible.
   at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
   at ChargeBee.Api.EntityRequest`1.Header(String headerName, String headerValue)
   at Program.<Main>$(String[] args) in ......

Notes

It looks like this error occurs in all requests that have type EntityRequest<Type>.
The error is thrown here: (T) Convert.ChangeType((object) this, typeof (T));.
It also means that for such requests it's not possible to set idempotency key or add a parameter to such request.

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