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

Preview template returns error #92

Closed
seymour7 opened this issue Mar 23, 2016 · 1 comment
Closed

Preview template returns error #92

seymour7 opened this issue Mar 23, 2016 · 1 comment
Milestone

Comments

@seymour7
Copy link

When running the following code

    sub_data = {'content': html}

    result = sparkpost_client.templates.preview(
        template_id='newsletter',
        substitution_data=sub_data,
        draft=False
    )

I get the following error:

required field is missing: field 'substitution_data' is required

I think it may be because, in templates.py, line 181:

data=json.dumps(substitution_data))

You can't just simply dump the json, need to append it to a new dict with the "substitution_data" key before doing that.

I'm fairly sure this is the issue because if i change my code like so:

    sub_data = {'substitution_data': {'content': html}}

    result = sparkpost_client.templates.preview(
        template_id=config.item['sparkpost_template'],
        substitution_data=sub_data,
        draft=False
    )

It works.

@richleland
Copy link
Contributor

Hi @seymour7 would you have some time to review #97?

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