mailjet / mailjet-apiv3-nodejs

[API v3] Official Mailjet API v3 NodeJS wrapper
https://dev.mailjet.com
MIT License
235 stars 69 forks source link

ERROR 500 : 'Cannot convert data from object value' #224

Closed bentoutcour closed 2 years ago

bentoutcour commented 2 years ago

Hello,

I keep having this issue when I use the template provided by Mailjet to use in Node.js. The data inside "Messages" aren't read weirdly, and the error log isn't really helpful to solve it : statusCode: 500, statusText: 'Cannot convert data from object value',

The data block looks like that:

data: '{"Messages":[{"FromEmail":{"Email":"my email in string","Name":"Ben"},"To":[{"addressEmail":"the email adress I send it to","Name":"Ben"}],"Subject":"Your email flight plan!","TextPart":"Dear passenger 1, welcome to Mailjet! May the delivery force be with you!","HTMLPart":"May the delivery force be with you!","CustomID":"AppGettingStartedTest"}]}',

Has someone ever encountered such issue?

Thank you in advance for your kind help,

Have a good day,

Ben

bentoutcour commented 2 years ago

The issue was that I wasn't specifying which version of Mailjet API I was using for the Messages request, thus the API was by default using the V3 email formatting template and not the V3.1 version that I was using.

A solution is to switch to the V3 version : https://dev.mailjet.com/email/guides/send-api-V3/ instead of the V3.1