Closed Marcosaurios closed 3 years ago
Hey @Marcosaurios
In order to print the exact error message as you would receive on hitting the APIv3 directly you need to print the error object as in the following code:
Also, you can open a ticket with our support team from your Sendinblue account so that they can get back to you promptly.
Note: You can print the other keys inside the error object using console.log(Object.keys(error)). Let me know if you need any help further.
let defaultClient = SibApiV3Sdk.ApiClient.instance;
let apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = "YOUR-API-KEY";
let apiInstance = new SibApiV3Sdk.ContactsApi();
let createContact = new SibApiV3Sdk.CreateContact();
createContact.email = 'example@example.com';
createContact.listIds = [2];
createContact.attributes = {
"sms":"1234"
}
apiInstance.createContact(createContact).then(function(data) {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}, function(error) {
console.log(error.status);
console.log(JSON.stringify(error.response.body));
});
I've been implementing creating a new Contact on my Node API and I've found some strange kind of bug with SMS.
When I create a new contact with SMS<6 characters length returns this error message:
But when I create a new one with SMS>6 characters length it creates ok. It seems to be in your
superagent
dependency. Or if you're validating SMS length (that I didn't find it in the repo) it will be better if the API error message will be something like 'Invalid SMS length' or so.P.D.: I'm creating a new contact with that: