Skip to content

Cannot submit multiple categories to Categories Statistics endpoint #186

Closed

Description

@chrishenry

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

Activity

  1. thinkingserious commented on Jul 8, 2016

    @thinkingserious
    Contributor
  2. ninadamondikar commented on Sep 10, 2017

    @ninadamondikar

    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!

  3. thinkingserious commented on Sep 11, 2017

    @thinkingserious
    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

  4. ninadamondikar commented on Sep 12, 2017

    @ninadamondikar

    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

  5. thinkingserious commented on Sep 12, 2017

    @thinkingserious
    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions