Workflows in Symphonie can be triggered by many different conditions: polling from a segment, a new recipient added to the system, an open
or click-through, adding to an Offline Event, or by explicitly adding a recipient using the API. This example demonstrates adding a recipient to an existing,
known workflow. Workflows can be configured to allow a recipient to enter only one time, to allow multiple entries for the same recipient once the workflow
has completed, or to allow the recipient to be in the workflow many times simultaneously. The API will report an error if the recipient cannot be inserted.
Adding a recipient to a workflow triggers the workflow to immediately begin processing the steps for that recipient.
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Text.Json;
using System.Threading.Tasks;
private static async Task RestExample4(HttpClient client, List<string> emailAddresses)
{
var body = new
{
accountName = "acme",
login = "ApiUser",
password = "YOUR_PASSWORD",
workflowName = "API Add Test",
emailAddresses
};
using (HttpResponseMessage response =
await client.PostAsJsonAsync("https://example.com/API/Rest/Workflows/Add", body))
{
response.EnsureSuccessStatusCode();
string result = await response.Content.ReadAsStringAsync();
if (!result.TrimStart().StartsWith("{"))
{
Console.WriteLine(result);
return;
}
using (JsonDocument data = JsonDocument.Parse(result))
{
foreach (JsonElement row in data.RootElement.GetProperty("notInDatabase").EnumerateArray())
Console.WriteLine(row.GetString() + " is not in the database");
foreach (JsonElement row in data.RootElement.GetProperty("previouslyInWorkflow").EnumerateArray())
Console.WriteLine(row.GetString() + " has already been in the workflow");
foreach (JsonElement row in data.RootElement.GetProperty("duplicateInFile").EnumerateArray())
Console.WriteLine(row.GetString() + " was duplicated in the input");
}
}
}
# encoding: utf-8
require 'rest-client'
require 'json'
emails = ["bert@example.com","joe@example.com","Pdhhdffgd", "joe@example.com"]
url = "https://example.com/api/rest/Workflows/Add"
data = {"accountName":"acme", "login":"ApiUser", "password":"YOUR_PASSWORD", "workflowName":"API Add Test",
'emailAddresses':[]}
data["emailAddresses"] = emails
resp = RestClient.post url, data.to_json, {"Content-Type": "application/json"}
if resp.code != 200
puts "Add to workflow failed!"
puts resp.code
exit
end
if resp.body[0] == "{"
data = JSON.parse resp.body
for row in data["notInDatabase"]
puts row + " in not in the database"
end
for row in data["previouslyInWorkflow"]
puts row + " has already been in the workflow"
end
for row in data["duplicateInFile"]
puts row + " was duplicated in the input"
end
else
puts resp.body
end
import requests
import json
def workflows(emails):
url = "https://example.com/api/rest/Workflows/Add"
data = {"accountName":"acme", "login":"ApiUser", "password":"YOUR_PASSWORD", "workflowName":"API Add Test",
'emailAddresses':[]}
data["emailAddresses"] += emails
resp = requests.post(url, json=data, headers={"Content-Type": "application/json"})
if resp.status_code != 200:
print("Add to workflow failed!")
print(resp.status_code)
return
if resp.text[0] == "{":
data = json.loads(resp.text)
for row in data["notInDatabase"]:
print(row + " is not in the database")
for row in data["previouslyInWorkflow"]:
print(row + " has already been in the workflow")
for row in data["duplicateInFile"]:
print(row + " was duplicated in the input")
else:
print(resp.text)
workflows(["joe@example.com","sam@example.com","Pdhhdffgd", "sam@example.com"])