sendEmail Function via API
Hi Team.
I'm using this method:
With the below details from postman (replaced inputs{} for this question)
```
POST https://{company}.domo.com/api/codeengine/v2/packages/{package_id_found_in_url}/versions/{version_integers}/functions/sendEmail
Authorization: Token (generated via Admin > Access Tokens)
body (JSON) {
"inputVariables": {
"subject": "This is a test",
"text": "Hi there - I'm checking this lands in the body of the email",
"recipientsUserIds": [integer]
},
"settings": { "getLogs": false
}
I'm getting the following error:
{
"executionId": "",
"packageId": "this matches the input - redacted for the question",
"version": "matches input",
"functionName": "sendEmail",
"status": "FAILED",
"settings": {
"getLogs": false
},
"startedOn": "2025-02-26T20:29:32.665Z",
"startedBy": "user_id matched",
"completedOn": "2025-02-26T20:29:33Z",
"result": null,
"stdout": null,
"stderr": {
"log": [
"TypeError: Cannot read properties of null (reading 'length')\n at sendEmail (/var/task/function.js:63:45)\n at execute (/var/task/executor.js:47:44)\n at Object.<anonymous> (/var/task/executor.js:77:1)\n at Module._compile (node:internal/modules/cjs/loader:1469:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)\n at Module.load (node:internal/modules/cjs/loader:1288:32)\n at Module._load (node:internal/modules/cjs/loader:1104:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"
]
},
"errorInformation": null
}
Please can someone advise (it's a response status of 200 so blackbox from there for me.
Best Answer
-
Hi!
The CodeEngine API will always return a 200 with information about your function execution.
You can read into the stdout, stderr, status, and errorInformation fields for more information. To retrieve the stdout logs (console.log in JavaScript or print in python) you can call the API with the getLogs setting as true in the request body.
In this case it looks like an array isn't being passed into the inputVariables, yet on line 63 of your package it tries to access the length of that variable. Is this the globally available sendEmail function from the DOMO Notifications package? If so, what version?
I believe the body should look like
{ "inputVariables": {
"subject": "My Subject", "body": "My Email Body", "personRecipients": ["{userId}"], "groupRecipients": [], "attachments": [] }, "settings": { "getLogs": true } }- You can also open your package, and then open your dev tools and look at the network request made when you start your function and it works successfully. This should give you a working request body you can use in postman.
- Any additional information you have would be great in helping get this working!
0
Answers
-
Hi!
The CodeEngine API will always return a 200 with information about your function execution.
You can read into the stdout, stderr, status, and errorInformation fields for more information. To retrieve the stdout logs (console.log in JavaScript or print in python) you can call the API with the getLogs setting as true in the request body.
In this case it looks like an array isn't being passed into the inputVariables, yet on line 63 of your package it tries to access the length of that variable. Is this the globally available sendEmail function from the DOMO Notifications package? If so, what version?
I believe the body should look like
{ "inputVariables": {
"subject": "My Subject", "body": "My Email Body", "personRecipients": ["{userId}"], "groupRecipients": [], "attachments": [] }, "settings": { "getLogs": true } }- You can also open your package, and then open your dev tools and look at the network request made when you start your function and it works successfully. This should give you a working request body you can use in postman.
- Any additional information you have would be great in helping get this working!
0 -
We discovered this problem in our sendEmail() function in CodeEngine. We have a fix ready and will be pushing it out soon.
0 -
Hi @jaden.hoenes thanks :
Yes it's the sendEmail function from Domo notifications version 2.1.6
You're right, it was the params name, I interpreted "any // these should match your function input parameters" from the documentation to mean the names of the variables the .js params get passed to (code engine fuction).
Thanks!0 -
While I'm here @jaden.hoenes I'm now looking to access the share content functions (to share a card) and getting a
Full authentication is required to access this resource
I've seen the authentication documentation and I'm doing this:
full_auth = "https://api.domo.com/oauth/token"
data = {
"grant_type": "client_credentials",
"scope": "data dashboard workflow user"
}
response = requests.post(full_auth, data=data, auth=client_id, secret")))
if response.status_code == 200:
access_token = response.json().get("access_token")This returns an access token, that I feed into this:
semi-psuedo: "shareCardWithPerson":
"version":"3.0.1",
"function_name": "shareCardWithPerson"
https://company.domo.com/api/codeengine/v2/packages/{package_id}/versions/{version}/functions/{function_name}" body = {
"inputVariables": {
"person": person,
"card_id": card_id,
},
"settings": { "getLogs": True
}
}I'm wondering if by "full auth" it means including "account", "audit" and the other scope option (I don't recall now)
0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 306 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 112 SQL DataFlows
- 649 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 787 Beast Mode
- 78 App Studio
- 43 Variables
- 742 Automate
- 187 Apps
- 474 APIs & Domo Developer
- 67 Workflows
- 14 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 406 Distribute
- 117 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 139 Manage
- 136 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive