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

Numeric values cause 400 Bad Request with no explanation #142

Closed
brian4d opened this issue Jan 27, 2017 · 6 comments · Fixed by #178
Closed

Numeric values cause 400 Bad Request with no explanation #142

brian4d opened this issue Jan 27, 2017 · 6 comments · Fixed by #178
Labels
difficulty: easy fix is easy in difficulty status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@brian4d
Copy link

brian4d commented Jan 27, 2017

Issue Summary

Was stumped briefly while upgrading to Ver 3 of the API. I had followed the example code but was getting "400 Bad Request" without any other explanation.

mail.custom_args = CustomArg.new(:key => 'list_id', :value => self.list_id)
mail.custom_args = CustomArg.new(:key => 'message_id', :value => self.id)
personalization.substitutions = Substitution.new(:key => '-person_id-', :value => subscriber.id)

Finally figured it might be caused by a few numeric values in the CustomArgs and Substitutions. Voila!

mail.custom_args = CustomArg.new(:key => 'list_id', :value => self.list_id.to_s)
mail.custom_args = CustomArg.new(:key => 'message_id', :value => self.id.to_s)
personalization.substitutions = Substitution.new(:key => '-person_id-', :value => subscriber.id.to_s)

It would be great if the gem automatically converted these values to strings -- particularly since the error message is so generic. Thanks.

Technical details:

  • sendgrid-ruby Version: master (latest commit: 4.0.6)
  • Ruby Version: 2.2
@thinkingserious
Copy link
Contributor

Hi @brian4d,

Agreed and thanks for taking the time to spell out the issue in detail!

I have added this to our backlog for implementation.

With Best Regards,

Elmer

@thinkingserious thinkingserious added status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap labels Jan 27, 2017
@percyhanna
Copy link

Any word on fixing this? Ideally the API would just return a better error message, and/or accept any valid JSON in custom_args (or at least any scalar values).

@thinkingserious
Copy link
Contributor

Hi @percyhanna,

I've added your vote to this issue to help it rise in our backlog. It can continue to rise with additional +1s, comments or a PR. A PR would cause the greatest impact.

Thanks!

Elmer

@thinkingserious thinkingserious added difficulty: easy fix is easy in difficulty hacktoberfest labels Sep 30, 2017
@sitaramshelke
Copy link
Contributor

Hey @thinkingserious can I help with this?
It looks like a simple fix in initialize in custom_arg.rb
I guess sometimes id fields are ruby objects and not string which caused the issue.

@thinkingserious
Copy link
Contributor

Thanks @sitaramshelke! It's all yours :)

@percyhanna
Copy link

Thanks @sitaramshelke !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy fix is easy in difficulty status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants