recurly/recurly-client-dotnet

Error getting objects by id

glennsdavis opened this issue · 4 comments

Warning: Github issues are not an official support channel for Recurly. If you have an urgent request we suggest you contact us through an official channel: support@recurly.com or https://recurly.zendesk.com

Describe the bug

I get an error when using the API to get objects by id. The error is "Please remove the following unpermitted parameters from your request: limit."

The reference documentation states that the ids parameter cannot be used with any other ordering or filtering parameters (limit, order, sort, begin_time, end_time, etc). The API defaults "limit" parameter to null, but it does not appear the API is excluding the limit parameter in the request to the server.

public Pager ListAccountSubscriptions(string accountId, string ids = null, int? limit = null, string order = null, string sort = null, DateTime? beginTime = null, DateTime? endTime = null, string state = null, RequestOptions options = null);

To Reproduce

Pager subscriptions = client.ListAccountSubscriptions("code-2938", "obdmcbsp424h");
Subscription subscription = subscriptions.First();

Pager invoices = client.ListAccountInvoices("code-2938", "obdmcbsqilaa");
Invoice invoice = invoices.First();

Expected behavior

Calls do not throw an exception and the requested object is returned.

Your Environment

SDK: Recurly V3 API - v3.18.0
Language: C#
Framework: .NET 5.0

Hello @glennsdavis, thanks for creating this issue.

It is not well documented, but the First() method will specify the limit parameter to the value 1. As such, it should not be used when specifying ids.

public T First()
{
    Dictionary<string, object> firstParams = new Dictionary<string, object>(QueryParams);
    firstParams["limit"] = 1;
    var pager = RecurlyClient.MakeRequest<Pager<T>>(Method.GET, Url, null, firstParams, Options);
    return pager.Data.FirstOrDefault();
}

If you're operating with a known list of ids then I would suggest using the get_subscription and get_invoice operations if you're only interested in a single subscription/invoice. Otherwise, you should just iterate over the Pager results.

Ah okay, glad to share the info then!

As far as braintree is concerned, I think that Recurly support would be better equipped to answer those types of questions.

Close this issue.