N
Novu•12mo ago
ksingh

Unable to send multi-recipients email using curl command

Hi, I am trying to send email using curl command. I am able to send email to single recipient but not able to send email to multiple recipients. I am using below command to send email to multiple recipients.
curl --location --request POST 'https://api.novu.co/v1/events/trigger' \
--header 'Authorization: ApiKey 7743223b3a9c2130eddb21ff33se3' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "scogo-link-down-notification",
"to": {
subscriberId: '65659176b4e3ba927d54432',
},
"overrides": {
"email": {
senderName: 'Novu Team'
text: 'text version of email using overrides',
replyTo: '[email protected]',
"cc": ['[email protected]'],
"bcc": ['[email protected]'],
},
},
}'
curl --location --request POST 'https://api.novu.co/v1/events/trigger' \
--header 'Authorization: ApiKey 7743223b3a9c2130eddb21ff33se3' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "scogo-link-down-notification",
"to": {
subscriberId: '65659176b4e3ba927d54432',
},
"overrides": {
"email": {
senderName: 'Novu Team'
text: 'text version of email using overrides',
replyTo: '[email protected]',
"cc": ['[email protected]'],
"bcc": ['[email protected]'],
},
},
}'
17 Replies
ksingh
ksinghOP•12mo ago
- I also tried to create multiple subscribers using the following command but it did not work
curl --location --request POST 'https://api.novu.co/v1/events/trigger' \
--header 'Authorization: ApiKey 7743223b3a9c2130eddb21fd1be' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "ssss-link-down-notification",
"to": {
"subscriberId": "65659176b4e3ba927d508852,65659176b4e3ba927d508853,65659176b4e3ba927d508854",
},
"payload": {}
}'
curl --location --request POST 'https://api.novu.co/v1/events/trigger' \
--header 'Authorization: ApiKey 7743223b3a9c2130eddb21fd1be' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "ssss-link-down-notification",
"to": {
"subscriberId": "65659176b4e3ba927d508852,65659176b4e3ba927d508853,65659176b4e3ba927d508854",
},
"payload": {}
}'
i am getting this error
{"message":"Unexpected token } in JSON at position 144","error":"Bad Request","statusCode":400}
{"message":"Unexpected token } in JSON at position 144","error":"Bad Request","statusCode":400}
@Support can you pls guide @DevRel @Product
sumitsaurabh927
sumitsaurabh927•12mo ago
Hi @ksingh to send emails to multiple subscribers, you first need to create a topic. Topics are essentially a way to bulk send notifications. First create a topic and add all the subscribers to it. Can you try that? Also, avoid tagging 'product'. For support queries, you can use 'support' and 'devrel' roles. Thanks!
Pawan Jain
Pawan Jain•12mo ago
@ksingh comma is missing after senderName: 'Novu Team' in above curl request. I see this is also missing in documentation. We will update the doc for 2nd curl request, correct format is as below
curl --location --request POST 'https://api.novu.co/v1/events/trigger' \
--header 'Authorization: ApiKey 7743223b3a9c2130eddb21fd1be' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "ssss-link-down-notification",
"to": ["65659176b4e3ba927d508852","65659176b4e3ba927d508853","65659176b4e3ba927d508854"],
"payload": {}
}'
curl --location --request POST 'https://api.novu.co/v1/events/trigger' \
--header 'Authorization: ApiKey 7743223b3a9c2130eddb21fd1be' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "ssss-link-down-notification",
"to": ["65659176b4e3ba927d508852","65659176b4e3ba927d508853","65659176b4e3ba927d508854"],
"payload": {}
}'
+ as sumit suggested, checkout topics as well to trigger workflow to group of subscribers
ksingh
ksinghOP•12mo ago
@Pawan Jain @sumitsaurabh927 Thanks for the support. I found Novu 3 hours back and i am able to sent out notifications. You guys have build a great product. I am currently experimenting with Novu and checking if this could be used in our existing setup. @sumitsaurabh927 the topic make sense, i will try that, can you help me with the CURL examples to create and mange topics if you have that handy one last thing, can one of you help me identifiy whats wrong with this CURL
curl --location --request POST 'https://api.novu.co/v1/subscribers' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: ApiKey 7743223b3a9c2130eee' \
--data-raw '{
"subscriberId": ["65659176b4e3ba926d508852"],
"email": "keeeee",
"firstName": "Kddd",
"lastName": "Bbbbb",
"phone": "+913333",
}'
curl --location --request POST 'https://api.novu.co/v1/subscribers' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: ApiKey 7743223b3a9c2130eee' \
--data-raw '{
"subscriberId": ["65659176b4e3ba926d508852"],
"email": "keeeee",
"firstName": "Kddd",
"lastName": "Bbbbb",
"phone": "+913333",
}'
i am getting this {"message":"Unexpected token } in JSON at position 144","error":"Bad Request","statusCode":400}%
sumitsaurabh927
sumitsaurabh927•12mo ago
Thank you for such a generous comment @ksingh We hope you like our product and please feel free to drop in any more questions you have or any feature request. As for the CURL examples, we don't have that in our docs as of now but I'm creating an issue for it. It'll be added soon enough. 🙂
ksingh
ksinghOP•12mo ago
it would have been great if the error message can point to the line number as well in addition to position, i am still wondering which param of the data-raw has issues 😓
Novu_Bot
Novu_Bot•12mo ago
@ksingh, you just advanced to level 1!
ksingh
ksinghOP•12mo ago
Thanks , once i have a good understanding of Novu, happy to create PRs. Meanwhile it would be great if you can just review the curl above @sumitsaurabh927 @Keyur Bhole
sumitsaurabh927
sumitsaurabh927•12mo ago
We do have CURL snippets here for topic creation. Did you check this @ksingh ?
ksingh
ksinghOP•12mo ago
Thanks @sumitsaurabh927 this helped
ksingh
ksinghOP•12mo ago
@Pawan Jain @sumitsaurabh927 sorry to bother you again . I am trying to send to multiple subscribers as per the curl command suggested by @Pawan Jain . While running the command i am getting success message (below) however the receipients are not getting actual email. While looking at web.novu.co activities , i am seeing this error ?
No description
ksingh
ksinghOP•12mo ago
Is that a backend issue ? or something success message from curl request {"data":{"acknowledged":true,"status":"processed","transactionId":"e4cae4e6-3368-402a-a17b-0ea77717c622"}} and. just for the record , all subscribers have a valid email. If i send email just to 1 subscriber , i receive the email, but failing when sending to 2 subscribers
Pawan Jain
Pawan Jain•12mo ago
@ksingh Can you try with this to format
"to": ["65659176b4e3ba927d508852","65659176b4e3ba927d508853","65659176b4e3ba927d508854"]
"to": ["65659176b4e3ba927d508852","65659176b4e3ba927d508853","65659176b4e3ba927d508854"]
ksingh
ksinghOP•12mo ago
@Pawan Jain this worked, however on UI , it shows 3 separate items (i was expecting just 1 with details of 3 subscriberID in trigger information section on the UI).
No description
ksingh
ksinghOP•12mo ago
Well this is not a bug, but a representation of data on UI
Pawan Jain
Pawan Jain•12mo ago
As per above curl, there are three subscriberId in to field. Novu takes one workflow trigger to one subscriber as one event(notification) item
ksingh
ksinghOP•12mo ago
This explains
Want results from more Discord servers?
Add your server