vonage-node-code-snippets icon indicating copy to clipboard operation
vonage-node-code-snippets copied to clipboard

Errors#InvalidParams

Open kopi-kosong opened this issue 5 years ago • 3 comments

Hi, there,

when I tried to execute the code, i encountered an issue as following:

{ body: { type: 'https://www.nexmo.com/messages/Errors#InvalidParams', title: "Your request parameters didn't validate.", detail: 'Found errors validating 1 of your submitted parameters.', instance: 'db405d542048f2a68872a54563448edd', invalid_parameters: [ [Object] ] }, headers: { date: 'Thu, 19 Mar 2020 01:41:44 GMT', 'content-type': 'application/problem+json', 'content-length': '315', connection: 'close', 'set-cookie': [ '__cfduid=d2bf53fcbb748b251b9fcb0684ee565781584582104; expires=Sat, 18-Apr-20 01:41:44 GMT; path=/; domain=.nexmo.com; HttpOnly; SameSite=Lax' ], 'x-frame-options': 'deny', 'x-xss-protection': '1; mode=block;', 'strict-transport-security': 'max-age=31536000; includeSubdomains', 'x-content-type-options': 'nosniff', 'content-disposition': 'attachment; filename="api.txt"', 'x-nexmo-trace-id': 'db405d542048f2a68872a54563448edd', 'cf-cache-status': 'DYNAMIC', 'expect-ct': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', server: 'cloudflare', 'cf-ray': '57637e277c1884b8-HKG' }, statusCode: 400 }

I could not figure out where the problem is from. Could you please help?

Thank you.

kopi-kosong avatar Mar 19 '20 02:03 kopi-kosong

Hi, can I see the code you're trying to run?

The error should have better information as well if you log error.invalid_parameters[0]

AlexLakatos avatar Mar 19 '20 14:03 AlexLakatos

Here is my source:

/require('dotenv').config({path: __dirname + '/../.env'})/

const Nexmo = require('nexmo');

const nexmo = new Nexmo({ apiKey: '267a8d9f', apiSecret: 'D9Qxqddp2fdBprAt', applicationId: 'ea92b0c9-b1c4-42f9-a37b-3c39fdacb2e9', privateKey: 'C:/george/12.Apps/keys/nexmo/whatsapp_key/private.key'

});

const message = { content: { type: 'text', text: 'Hello from Nexmo', }, };

// This example lets you try it out with our test account. // Find out how you can get a WhatsApp approved business account here: // https://developer.nexmo.com/messages/concepts/whatsapp nexmo.channel.send( { type: 'whatsapp', number: '6590110222' }, { type: 'whatsapp', number: '6590110222' }, message,

// (err, data) => { console.log(data.message_uuid);}

(err, data) => { if (err) { console.log(err) } else { console.log(data.message_uuid); } } );

kopi-kosong avatar Mar 19 '20 15:03 kopi-kosong

Sorry, Alex,

Shall I try to log error with "console.log(err.invalid_parameters[0]);"?

This line gave me another error: console.log(err.invalid_parameters[0]); ^

TypeError: Cannot read property '0' of undefined at C:\george\12.Apps\sendNexmoSMS\sendWhatapp.js:34:37 at HttpClient.__parseResponse (C:\george\12.Apps\sendNexmoSMS\node_modules\nexmo\lib\HttpClient.js:232:9) at IncomingMessage. (C:\george\12.Apps\sendNexmoSMS\node_modules\nexmo\lib\HttpClient.js:141:19) at IncomingMessage.emit (events.js:328:22) at endReadableNT (_stream_readable.js:1201:12) at processTicksAndRejections (internal/process/task_queues.js:84:21)

Or how to log the error param 0?

Thank you very much. :)

kopi-kosong avatar Mar 19 '20 15:03 kopi-kosong

Closing due to inactivity

dragonmantank avatar Nov 11 '22 14:11 dragonmantank