Sendgrid-php: Problem when using {key} as a substitution

Created on 16 Jul 2016  路  7Comments  路  Source: sendgrid/sendgrid-php

Issue Summary

We've been using the { and } symbol as the wrapper around our substitution tags. When migrating to v3, these come back with a '400 Bad Request'. Though the request works fine if I remove the substitutions section.

Steps to Reproduce

The JSON payload for the personalistion section is:

"personalizations": [{
    "to": [{
        "email": "[email protected]"
    }],
    "substitutions": {
        "{id}": 1,
        "{name}": "Lewis Theobald",
        "{forename}": "Lewis",
        "{surname}": "Theobald"
    }
}]

The response is:

{
  "errors": [
    {
      "message": "Bad Request",
      "field": null,
      "help": null
    }
  ]
}

If I remove the substitutions block or change it to another symbol, we receive '202 Accepted'.

Technical details:

  • sendgrid-php Version: master (latest commit: [commit number])
  • PHP Version: 5.x
help wanted community enhancement

Most helpful comment

Actually, it spanned from only the single item

"{id}": 1

Should actually be

"{id}":"1"

Requires all parameters to be sent over as string enclosed in quotes. Should make this aware somewhere in the Personalizations section

All 7 comments

Actually, it spanned from only the single item

"{id}": 1

Should actually be

"{id}":"1"

Requires all parameters to be sent over as string enclosed in quotes. Should make this aware somewhere in the Personalizations section

Thank you @LewisTheobald!

I will leave this ticket open until we update the docs and code to clarify.

I will leave this ticket open until we update the docs and code to clarify.

Can you update the the error object that is sent back to include more information than

{"errors":[{"message":"Bad Request","field":null,"help":null}]}

I didn't find this to be very useful in diagnosing the problem

@csaroff,

Yes, that will be part of the update.

Thanks for taking the time to provide feedback!

@LewisTheobald thanks saved me a few hours of debugging.

@LewisTheobald,

Please take a moment to fill out this form so we can send you some swag :)

With Best Regards,

Elmer

This has been moved here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

moontrv picture moontrv  路  3Comments

rainman0607 picture rainman0607  路  4Comments

peluprvi picture peluprvi  路  5Comments

bjornmann picture bjornmann  路  3Comments

iamanupammaity picture iamanupammaity  路  4Comments