Closed harshalyeole-tudip closed 7 years ago
Hi @harshalyeole-tudip, Based on the data you provided you are using new the Send API v3.1 (https://api.mailjet.com/v3.1/send). The message format, plus some additional properties were changed and you should use the new format. Please take a look at Send API v3.1 example from the guide and update your code accordignly. If you need further assistance, let me know.
Note: You can still use the Send API v3 if you prefer to, but we suggest you to use the new one.
Thanks.
Now I updated my code and Now I'm using following code: const mailjet = require ('node-mailjet') .connect('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'); const request = mailjet .post("send", {'version': 'v3.1'}) .request({ "Messages":[ { "From": { "Email": "opto@optosystem-marketing.com", "Name": "OPTO" }, "To": [ { "Email": "ankit@zibtek.com", "Name": "Ankit" } ], "Subject": "Your email flight plan!", "TextPart": "Dear passenger, welcome to Mailjet! May the delivery force be with you!", "HTMLPart": "
GETTING ERROR:
{"ErrorIdentifier":"10224e30-2f6d-4dc6-a7bc-57a9cb505b44","StatusCode":500,"ErrorMessage":"Ouch! Something went wrong on our side and we apologize! Please contact our support team who’ll be able to help you on this"}', method: 'POST', path: '/v3.1/send' }
WHOLE ERROR:
{ Error: Unsuccessful
at /home/lt-101/OptoWebsite2017/node_modules/node-mailjet/mailjet-client.js:220:23
at Request.callback (/home/lt-101/OptoWebsite2017/node_modules/node-mailjet/node_modules/superagent/lib/node/index.js:699:3)
at /home/lt-101/OptoWebsite2017/node_modules/node-mailjet/node_modules/superagent/lib/node/index.js:868:18
at IncomingMessage.
I have raised a support ticket as well.
Hello @harshalyeole-tudip , I hope our support staff has been able to assist you. If not feel free to reopen the ticket.
const request = this.objMail .post("send", { 'version': 'v3.1' }) .request({ "Messages": [ { "From": { "Email": this._config.mail_from }, "To": [ { "Email": to } ], "Subject": subject, "HTMLPart": html } ] }); request .then((result) => { console.log('Success'); console.log(result); }) .catch((err) => { console.log(err); console.log(err.statusCode); });
-- Getting Error - Unsuccessful: null Parse Error
Complete error log - { Error: Unsuccessful: null Parse Error at /home/XXXXX/XXXX//node_modules/node-mailjet/mailjet-client.js:321:23 at Request.callback (/home/XXXXX/XXXX/node_modules/superagent/lib/node/index.js:728:3) at ClientRequest.req.once.err (/home/XXXXX/XXXX/node_modules/superagent/lib/node/index.js:647:10) at Object.onceWrapper (events.js:315:30) at emitOne (events.js:116:13) at ClientRequest.emit (events.js:211:7) at TLSSocket.socketOnData (_http_client.js:445:9) at emitOne (events.js:116:13) at TLSSocket.emit (events.js:211:7) at addChunk (_stream_readable.js:263:12) at readableAddChunk (_stream_readable.js:250:11) at TLSSocket.Readable.push (_stream_readable.js:208:10) at TLSWrap.onread (net.js:607:20) ErrorMessage: 'Parse Error', ErrorIdentifier: undefined, statusCode: null, response: null, message: 'Unsuccessful: null Parse Error' }
I'm having the same issue as ghosthyper
mailjet = require('node-mailjet').connect('XXXXXXX', 'XXXXX', { url: 'in-v3.mailjet.com', // default is the API url version: 'v3.1', // default is '/v3' perform_api_call: true // used for tests. default is true });
mailjet.post("send").request({ "Messages": [ { "From": { "Email": "pilot@mailjet.com", "Name": "Mailjet Pilot" }, "To": [ { "Email": "julesmqz@gmail.com", "Name": "Julio Marquez" } ], "Subject": "Your email flight plan!", "TextPart": "Dear passenger 1, welcome to Mailjet! May the delivery force be with you!", "HTMLPart": "
COOL
" } ] }).then((result) => { console.log('Success'); console.log(result); }) .catch((err) => { console.log(err); console.log(err.statusCode); });{ Error: Unsuccessful: null Parse Error at /Applications/XAMPP/xamppfiles/htdocs/zoogdl/functions/node_modules/node-mailjet/mailjet-client.js:321:23 at Request.callback (/Applications/XAMPP/xamppfiles/htdocs/zoogdl/functions/node_modules/superagent/lib/node/index.js:728:3) at ClientRequest.req.once.err (/Applications/XAMPP/xamppfiles/htdocs/zoogdl/functions/node_modules/superagent/lib/node/index.js:647:10) at Object.onceWrapper (events.js:286:20) at ClientRequest.emit (events.js:198:13) at TLSSocket.socketOnData (_http_client.js:448:9) at TLSSocket.emit (events.js:198:13) at addChunk (_stream_readable.js:288:12) at readableAddChunk (_stream_readable.js:269:11) at TLSSocket.Readable.push (_stream_readable.js:224:10) at TLSWrap.onStreamRead (internal/stream_base_commons.js:94:17) ErrorMessage: 'Parse Error', ErrorIdentifier: undefined, statusCode: null, response: null, message: 'Unsuccessful: null Parse Error' }
Hi All,
I tried the demo code provided and I am facing an error.
This error only occurs when I use my paid account instead of test account.
This is my code: `var mailjet = require ('./mailjet-client') .connect('XXXXXXXXXXXXXXXXXXXXXXXX', 'XXXXXXXXXXXXXXXXXXXXXXXX')
function handleError (err) { console.log(err); throw new Error(err.ErrorMessage); }
function newContact (email) { mailjet.post('contact') .request({Email: email}) .catch(handleError); }
function testEmail (text) { email = {}; email.FromName = 'Your Name'; email.FromEmail = 'Your Sender Address'; email.Subject = 'Test Email'; email.Recipients = [{Email: 'Your email'}]; email['Text-Part'] = text;
mailjet.post('send') .request(email) .catch(handleError); }
testEmail('Hello World!');`
This is my Error:
Error: Unsuccessful at /home/lt-101/Folder/node_modules/node-mailjet/mailjet-client.js:220:23 at Request.callback (/home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/index.js:699:3) at /home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/index.js:868:18 at IncomingMessage.<anonymous> (/home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/parsers/json.js:16:7) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) ErrorMessage: 'Bad Request', statusCode: 400, response: Response { domain: null, _events: {}, _eventsCount: 0, _maxListeners: undefined, res: IncomingMessage { _readableState: [Object], readable: false, domain: null, _events: [Object], _eventsCount: 4, _maxListeners: undefined, socket: [Object], connection: [Object], httpVersionMajor: 1, httpVersionMinor: 1, httpVersion: '1.1', complete: true, headers: [Object], rawHeaders: [Object], trailers: {}, rawTrailers: [], upgrade: false, url: '', method: null, statusCode: 400, statusMessage: 'Bad Request', client: [Object], _consuming: true, _dumped: false, req: [Object], text: '{"Errors":[{"ErrorIdentifier":"734c0518-b622-4a7f-999e-099d50cd032a","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["FromName"]},{"ErrorIdentifier":"7d57ed98-181e-47bb-a886-4a29ed4def91","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["FromEmail"]},{"ErrorIdentifier":"6a1767e1-6782-47af-a503-cc971d904857","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Subject"]},{"ErrorIdentifier":"7dcda3e0-398a-4b62-ad99-8673d154e4fb","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Recipients"]},{"ErrorIdentifier":"66027d33-1114-4c87-87ed-eb1bb634d841","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Text-Part"]},{"ErrorIdentifier":"6a4b9008-8652-4bc8-b120-b342c1c59c47","ErrorCode":"mj-0003","StatusCode":400,"ErrorMessage":"Missing mandatory property.","ErrorRelatedTo":["Messages"]}],"Messages":null}', read: [Function] }, request: Request { domain: null, _events: {}, _eventsCount: 0, _maxListeners: undefined, _agent: false, _formData: null, method: 'POST', url: 'https://api.mailjet.com/v3.1/send', _header: [Object], header: [Object], writable: true, _redirects: 0, _maxRedirects: 5, cookies: '', qs: {}, _query: [], qsRaw: [], _redirectList: [], _streamRequest: false, _data: [Object], req: [Object], protocol: 'https:', host: 'api.mailjet.com', _endCalled: true, _callback: [Function], res: [Object], response: [Circular], called: true }, req: ClientRequest { domain: null, _events: [Object], _eventsCount: 3, _maxListeners: undefined, output: [], outputEncodings: [], outputCallbacks: [], outputSize: 0, writable: true, _last: true, upgrading: false, chunkedEncoding: false, shouldKeepAlive: false, useChunkedEncodingByDefault: true, sendDate: false, _removedHeader: [Object], _contentLength: 160, _hasBody: true, _trailer: '', finished: true, _headerSent: true, socket: [Object], connection: [Object], _header: 'POST /v3.1/send HTTP/1.1\r\nHost: api.mailjet.com\r\nAccept-Encoding: gzip, deflate\r\nuser-agent: mailjet-api-v3-nodejs/3.2.1\r\nContent-type: application/json\r\nAuthorization: Basic NWI2NmU3YmM3ZDQzNzM1ODEyOTA4YzMxMWEyNDI2YmE6NDM0NGU3MzI5YjgzZmM5Yzc5YjcwOTU2YTM0YzI0NjY=\r\nContent-Length: 160\r\nConnection: close\r\n\r\n', _headers: [Object], _headerNames: [Object], _onPendingData: null, agent: [Object], socketPath: undefined, timeout: undefined, method: 'POST', path: '/v3.1/send', _ended: true, parser: null, res: [Object] }, text: '{"Errors":[{"ErrorIdentifier":"734c0518-b622-4a7f-999e-099d50cd032a","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["FromName"]},{"ErrorIdentifier":"7d57ed98-181e-47bb-a886-4a29ed4def91","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["FromEmail"]},{"ErrorIdentifier":"6a1767e1-6782-47af-a503-cc971d904857","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Subject"]},{"ErrorIdentifier":"7dcda3e0-398a-4b62-ad99-8673d154e4fb","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Recipients"]},{"ErrorIdentifier":"66027d33-1114-4c87-87ed-eb1bb634d841","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Text-Part"]},{"ErrorIdentifier":"6a4b9008-8652-4bc8-b120-b342c1c59c47","ErrorCode":"mj-0003","StatusCode":400,"ErrorMessage":"Missing mandatory property.","ErrorRelatedTo":["Messages"]}],"Messages":null}', body: { Errors: [Object], Messages: null }, files: undefined, buffered: true, headers: { 'content-length': '1049', 'content-type': 'application/json; charset=UTF-8', date: 'Mon, 11 Sep 2017 17:05:58 GMT', connection: 'close' }, header: { 'content-length': '1049', 'content-type': 'application/json; charset=UTF-8', date: 'Mon, 11 Sep 2017 17:05:58 GMT', connection: 'close' }, statusCode: 400, status: 400, statusType: 4, info: false, ok: false, redirect: false, clientError: true, serverError: false, error: { Error: cannot POST /v3.1/send (400) at Response.toError (/home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/response.js:94:13) at ResponseBase._setStatusProperties (/home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/response-base.js:122:16) at new Response (/home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/response.js:40:8) at Request._emitResponse (/home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/index.js:723:20) at /home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/index.js:868:38 at IncomingMessage.<anonymous> (/home/lt-101/Folder/node_modules/node-mailjet/node_modules/superagent/lib/node/parsers/json.js:16:7) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) status: 400, text: '{"Errors":[{"ErrorIdentifier":"734c0518-b622-4a7f-999e-099d50cd032a","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["FromName"]},{"ErrorIdentifier":"7d57ed98-181e-47bb-a886-4a29ed4def91","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["FromEmail"]},{"ErrorIdentifier":"6a1767e1-6782-47af-a503-cc971d904857","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Subject"]},{"ErrorIdentifier":"7dcda3e0-398a-4b62-ad99-8673d154e4fb","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Recipients"]},{"ErrorIdentifier":"66027d33-1114-4c87-87ed-eb1bb634d841","ErrorCode":"send-0001","StatusCode":400,"ErrorMessage":"Not a valid property.","ErrorRelatedTo":["Text-Part"]},{"ErrorIdentifier":"6a4b9008-8652-4bc8-b120-b342c1c59c47","ErrorCode":"mj-0003","StatusCode":400,"ErrorMessage":"Missing mandatory property.","ErrorRelatedTo":["Messages"]}],"Messages":null}', method: 'POST', path: '/v3.1/send' }, accepted: false, noContent: false, badRequest: true, unauthorized: false, notAcceptable: false, forbidden: false, notFound: false, type: 'application/json', charset: 'UTF-8', links: {}, setEncoding: [Function: bound ], redirects: [] } }
Thank you.