Open shelmire opened 3 years ago
Note that doing a query directly with curl DOES work, so the gem is not behaving as expected:
curl --request GET \
--url 'https://api.sendgrid.com/v3/messages?limit=10&query=to_email%3D%22testing%40sendgrid.net%22' \
--header 'authorization: Bearer <<api_key>>'
Or
curl --request GET \
--url 'https://api.sendgrid.com/v3/messages?limit=10&query=last_event_time%20BETWEEN%20TIMESTAMP%20%22#{s}%22%20AND%20TIMESTAMP%20%22#{e}%22' \
--header "authorization: Bearer $SENDGRID_API_KEY"
Or
curl --request GET --url 'https://api.sendgrid.com/v3/messages?limit=10&query=last_event_time%20%3E%20TIMESTAMP%20%222021-01-07T20%3A02%3A25Z%22' --header "authorization: Bearer $SENDGRID_API_KEY"
Hello @shelmire,
I'm in the process of trying to reproduce this and I will post my findings here. Thank you!
With best regards,
Elmer
@thinkingserious Thanks!
Hello @shelmire,
Thank you for your patience!
I was able to reproduce this issue and confirm that via cURL your query works as expected and within this helper library the error you described is being thrown.
This issue has been added to our internal backlog to be prioritized. Pull requests and +1s on the issue summary will help it move up the backlog.
With best regards,
Elmer
Hello @thinkingserious,
The issue was we don't need to encode the query params, it is even mentioned in USAGE.md.
Queries may need to be URL encoded. URL encoding depends on how you're using the API - if you are trying it out here, or using one of the Libraries, we handle the encoding for you. If you are using cURL, or your own implementation, you probably need to encode it.
I have raised a PR for this issue. https://github.com/sendgrid/sendgrid-ruby/pull/485
Issue Summary
Getting messages via the described steps in the documentation does not work. Note that below I demonstrate that the example code fails.
Steps to Reproduce
Create a script with the following code (code copied exactly from the initialize step and this section), per https://github.com/sendgrid/sendgrid-ruby/blob/main/USAGE.md#email-activity .
Execute the script.
Observe error.
Note that what I really want to do is get any email status updates within the past hour or so (5 mins in example) with something like this, which should probably work according to https://sendgrid.com/docs/for-developers/sending-email/getting-started-email-activity-api/#creating-compound-queries:
Code Snippet
Exception/Log
Technical details: