Skip to content

Cannot submit multiple categories to Categories Statistics endpoint #186

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

Closed
chrishenry opened this issue Jul 2, 2016 · 5 comments
Closed
Labels
status: help wanted requesting help from the community type: bug bug in the library type: non-library issue API issue not solvable via the SDK

Comments

@chrishenry
Copy link

chrishenry commented Jul 2, 2016

Issue Summary

When using the client to get statistics for categories, it's not possible to submit multiple categories.

Steps to Reproduce

fun_stats = sg.client.categories.stats.get(query_params={
    'start_date': "2016-06-30",
    'categories': ['category1', 'category2'],
})

The above code makes a GET to this URL. Sendgrid returns a 404 for this request.

https://api.sendgrid.com/v3/categories/stats?categories=[u'category1', category2']&start_date=2016-06-30

When the correct behaviour is a GET with both category1 and category1 as values to categories. Sendgrid returns the expected response.

https://api.sendgrid.com/v3/categories/stats?categories=category1&categories=category2&start_date=2016-06-30

This seems to be a bug, as the Sendgrid docs clearly state sending multiple categories is supported, and there doesn't seem to be a way to do that with this client.

I believe the issue is actually here, in the python-http-client lib. urlencode should be passed a second parameter, (doseq), which will correctly format multiple values for parameters. (urlencode docs)

Technical details:

  • sendgrid-python Version: 3.0.0
  • Python Version: 2.7
@thinkingserious
Copy link
Contributor

Solved with sendgrid/python-http-client#11

@ninadamondikar
Copy link

ninadamondikar commented Sep 10, 2017

While multiple categories can be passed for Category Statistics, passing any more than 10 categories in the params leads to a 400 Bad Request error.

Code to Reproduce

cats = ['T1', 'T2, 'T3', 'T4', 'T5', 'T6', 'T7', 'T8', 'T9', 'T10', 'T11']
params = {'categories': cats,'start_date': '2017-05-01', 'end_date': '2017-09-01', 'aggregated_by': 'day',}

Is there a way this limit can be lifted?

Thanks!

@thinkingserious
Copy link
Contributor

Hi @ninadamondikar,

This is a limitation of the API. I will pass along your feedback to the product team. Could you please describe your use case?

With Best Regards,

Elmer

@ninadamondikar
Copy link

Hi -

My use case is that I am looking to export a dataset with all the stats for every single email category in my SendGrid account (which at this point is over a 100). This dataset will be used for internal reporting and analytics on email performance by being imported into a business intelligence software.

Currently, I have a workaround for this: making multiple calls offsetting each call by 10 starting from 0 and then combining the output. However as the number of categories keeps increasing lifting the cap on number of categories will help streamline the code.

Thanks!
Ninad

@thinkingserious
Copy link
Contributor

Hello @ninadamondikar,

Do you mind opening up a new issue specifically for this request? I'd like to try and get better visibility to increase its priority.

Thanks!

With Best Regards,

Elmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: bug bug in the library type: non-library issue API issue not solvable via the SDK
Projects
None yet
Development

No branches or pull requests

3 participants