Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error using cc or bcc with recipients substitution_data  #118

@medmunds

Description

@medmunds

At some point in the past couple of weeks, SparkPost started rejecting the cc recipient in the following call:

from sparkpost import SparkPost
sp = SparkPost()
result = sp.transmissions.send(
    from_email='[email protected]',  # use a valid sender for your account
    recipients=[{
        'address': {'email': '[email protected]'},
        'substitution_data': {'order_no': '12345'}
    }],
    cc=['[email protected]'],
    subject='test',
    text='test merge {{ order_no }}'
)
# {'total_rejected_recipients': 1, 'total_accepted_recipients': 1, 'id': '102374996990914834', 'rcpt_to_errors': [{'message': 'invalid data format/type', 'code': '1300', 'description': 'field \'recipients[1].address.header_to\' value \'{ "substitution_data": { "order_no": "12345" }, "address": { "email": "[email protected]" } }\' is of type \'json_object\', but needs to be of type \'string\''}]}

The problem seems to be in the payload's header_to generated for the cc. If you omit the cc parameter, it works fine. Similarly, if you change to a simple recipients=['[email protected]'], the send is accepted (albeit without the intended substitution data).

This worked (or at least was accepted by the API) on 2016-06-07. I don't believe python-sparkpost has changed during that period. Is this a problem in python-sparkpost, or an intentional API clarification/change? If the latter, is there way to specify substitution_data and cc (or bcc) in the same transmission?

python 3.5 (or 2.7); python-sparkpost 1.2.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions