passive-yellow
passive-yellow3mo ago

[Solved ✅] Failing to use API to execute function

I use composio's package to load schema but need to execute the function with custom logic. I am passing the data below but got the error 400: Validation failed - "App name and entity id must be present, if connected account id and endpoint are not present". How do I fix this?
import httpx
import json
import os

action_name = "OUTLOOK_OUTLOOK_SEND_EMAIL"
url = f"https://backend.composio.dev/api/v1/actions/{action_name}/execute"

headers = {
"Content-Type": "application/json",
"X-API-KEY": os.getenv("COMPOSIO_API_KEY"),
}

json_dict = {
"connectionId": "a246ce91-140e-421a-83f7-4794537c1a8b", # got this from 'Connected Accounts --> Account ID (change a digit for privacy)'
"input": {
"subject": "Hello",
"body": "How are you?",
"to_recipients": [{"address": "jessica@gmail.com"}]
}
}

client = httpx.Client()
response = client.post(
url=url,
headers=headers,
json=json_dict)

print(response.text)
import httpx
import json
import os

action_name = "OUTLOOK_OUTLOOK_SEND_EMAIL"
url = f"https://backend.composio.dev/api/v1/actions/{action_name}/execute"

headers = {
"Content-Type": "application/json",
"X-API-KEY": os.getenv("COMPOSIO_API_KEY"),
}

json_dict = {
"connectionId": "a246ce91-140e-421a-83f7-4794537c1a8b", # got this from 'Connected Accounts --> Account ID (change a digit for privacy)'
"input": {
"subject": "Hello",
"body": "How are you?",
"to_recipients": [{"address": "jessica@gmail.com"}]
}
}

client = httpx.Client()
response = client.post(
url=url,
headers=headers,
json=json_dict)

print(response.text)
4 Replies
dependent-tan
dependent-tan3mo ago
hey looking into this.
import requests

url = "https://backend.composio.dev/api/v1/actions/OUTLOOK_OUTLOOK_SEND_EMAIL/execute"

payload = {
"connectedAccountId": "xxxxxxxx",
"input": {
"subject": "testing",
"body": "hellooo",
"to_recipients": [{"address": "karthikeya@composio"}]
},
"appName": "OUTLOOK"
}
headers = {
"X-API-Key": "xxxxxxx",
"Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
import requests

url = "https://backend.composio.dev/api/v1/actions/OUTLOOK_OUTLOOK_SEND_EMAIL/execute"

payload = {
"connectedAccountId": "xxxxxxxx",
"input": {
"subject": "testing",
"body": "hellooo",
"to_recipients": [{"address": "karthikeya@composio"}]
},
"appName": "OUTLOOK"
}
headers = {
"X-API-Key": "xxxxxxx",
"Content-Type": "application/json"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
can you try this?
passive-yellow
passive-yellowOP3mo ago
It worked after changing "to_recipients" to "to_email". I deleted appName and it also worked. But you might wanna adjust the API doc as it uses "connectionId" instead of "connectedAccountId"?
dependent-tan
dependent-tan3mo ago
Sorry for this. We are updating the docs. Thanks for pointing this out!
passive-yellow
passive-yellowOP3mo ago
Hello! The "successfull" key in API tool execution result is mispelled.
{
"data":{
"message":"Email sent successfully."
},
"error":null,
"successfull":true
}
{
"data":{
"message":"Email sent successfully."
},
"error":null,
"successfull":true
}
@Karthikeya

Did you find this page helpful?