Open pinaf opened 7 years ago
Thank you for reporting this. We will fix this in the next release.
@pinaf
I ran RetrieveAllTemplatesSample and it worked. But looking at the From
spec it says Address “from” : "deals@company.com" or JSON object composed of the “name” and “email” fields “from” : { “name” : “My Company”, “email” : "deals@company.com" } used to compose the email’s “From” header
So yes the code needs to be smarter when parsing that template response. Currently it assumes it is the object form of the from address.
Can you tell me how you created that template so I can make sure I run and test your specific use-case?
Can you provide the JSON that is returned for the template that is failing? You can sanitize it by replacing your domain names with "example.com" and substitute strings for any other personal/confidential information.
Thanks.
@yepher so it seems that this might be an issue with the template being "old". Some of them return
"from": {
"name": "--redacted--",
"email": "--redacted--"
},
But others return
"from": "name <email>",
@yepher interesting. If I take one of the templates that return from
as a string and click save & publish without changing anything, upon a subsequent API call I get a json for from
@yepher I just confirmed that solves my problem (just re-publishing the templates). It's up to you whether you want the smarter parser or not :)
@pinaf, Awesome glad this is not holding you up. I think the code should handle the full spec so yes I think I will add it but I will make it a little lower priority now.
Using
sparkpost-lib 0.16.1
.When using
ResourceTemplates.retrieve
to retrieve a template, the followingJsonSyntaxException
occurs when parsing thefrom
field.It seems like the java code expects a JSON object but the API returns a simple string. Here is what the from field looks like when manually hitting the API at
https://api.sparkpost.com/api/v1/templates/mytemplate
with postman"from": "My Company <info@mycompany.com>",