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

use substitution_data parameters as string, not number #221

Closed
mariusa opened this issue Sep 21, 2017 · 3 comments
Closed

use substitution_data parameters as string, not number #221

mariusa opened this issue Sep 21, 2017 · 3 comments
Assignees

Comments

@mariusa
Copy link

mariusa commented Sep 21, 2017

When passing a substitution_data parameter as number which is over 2147483647, spark puts the number 2147483647 instead of the actual passed value.

Please treat all parameters as string, to avoid this issue.

@aydrian aydrian self-assigned this Sep 21, 2017
@aydrian
Copy link
Contributor

aydrian commented Sep 21, 2017

Hi. This library sends the JSON object unmodified to the SparkPost API. Can you please include an example? Parameters should be passed in the data type you are expecting them in the template. String is not the only data type allowed.

@mariusa
Copy link
Author

mariusa commented Sep 21, 2017

Hi,

email_body is a string as follows
"https://a.com?id={{id}}"


                var message = {
                    transmissionBody: {
                        options: {
                            open_tracking: false,
                            click_tracking: false
                        },
                        content: {
                            from: {
                                email: 'a@a.com',
                                name: 'a'
                            },
                            subject: "subj",
                            text: email_body
                        },

                        recipients: [{
                            address: {
                                email: ...
                            },
                            substitution_data: {
                                id: record_id
                            }
                        }]
                    }
                }

record_id is a number over 2b.
using record_id.toString() works. Is this required?

@aydrian
Copy link
Contributor

aydrian commented Sep 21, 2017

Yes. If you want it to be a string, you'll need to convert it to a string.
Sometimes I'll do this

record_id+''

or if you are using the new es2015 template literals, you can do

`${record_id}`

@aydrian aydrian closed this as completed Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants