Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error getting objects by id #609

Closed
glennsdavis opened this issue Feb 2, 2021 · 4 comments
Closed

Error getting objects by id #609

glennsdavis opened this issue Feb 2, 2021 · 4 comments
Assignees
Labels
bug? V3 v2019-10-10 Client

Comments

@glennsdavis
Copy link

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

@douglasmiller
Copy link
Contributor

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.

@douglasmiller douglasmiller self-assigned this Feb 3, 2021
@glennsdavis
Copy link
Author

glennsdavis commented Feb 4, 2021 via email

@douglasmiller
Copy link
Contributor

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.

@glennsdavis
Copy link
Author

Close this issue.

@jguidry-recurly jguidry-recurly added the V3 v2019-10-10 Client label Feb 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug? V3 v2019-10-10 Client
Projects
None yet
Development

No branches or pull requests

3 participants