Skip to content

CreateSubscriptionChange - validation error crashes client #698

@euang

Description

@euang

I'm calling CreateSubscriptionChange in 4.18 with a coupon that has already been redeemed on that subscription.

The api is returning this JSON which then fails to get parsed and throws this exception.

Newtonsoft.Json.JsonReaderException HResult=0x80131500 Message=Unexpected character encountered while parsing value: [. Path 'error.params[0].message', line 1, position 149. Source=Newtonsoft.Json StackTrace: at Newtonsoft.Json.JsonTextReader.ReadStringValue(ReadType readType) in /_/Src/Newtonsoft.Json/JsonTextReader.cs:line 671

JSON
{"error":{"type":"validation","message":"Coupon code [\"has reached max redemptions for this account\"]","params":[{"param":"coupon_code","message":["has reached max redemptions for this account"]}]}}

StackTrace
Newtonsoft.Json.dll!Newtonsoft.Json.JsonSerializer.Deserialize<Recurly.Errors.ApiErrorWrapper>(Newtonsoft.Json.JsonReader reader) Line 870
at /_/Src/Newtonsoft.Json/JsonSerializer.cs(870)
Recurly.dll!Recurly.JsonSerializer.Deserialize<Recurly.Errors.ApiErrorWrapper>(RestSharp.IRestResponse response) Line 72
at Recurly\JsonSerializer.cs(72)
Recurly.dll!Recurly.BaseClient.HandleResponse(RestSharp.IRestResponse resp) Line 269
at Recurly\BaseClient.cs(269)
Recurly.dll!Recurly.BaseClient.MakeRequest<Recurly.Resources.SubscriptionChange>(RestSharp.Method method, string url, Recurly.Request body, System.Collections.Generic.Dictionary<string, object> queryParams, Recurly.RequestOptions options) Line 169
at Recurly\BaseClient.cs(169)
Recurly.dll!Recurly.Client.CreateSubscriptionChange(string subscriptionId, Recurly.Resources.SubscriptionChangeCreate body, Recurly.RequestOptions options) Line 1813
at Recurly\Client.cs(1813)

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