Calling Automation Studio from function (or directive code)

Because of the need to loop thru multiple records in a Data Directive I can’t simply call the Automation Studio widget because I need a looping structure to call it multiple times.

My thought is to either use custom code in the directive or have the directive call a function.

I have the webhook url and required json parameters for the Automation Studio “recipe”.

Has anyone called Automation Studio via code and can provide an example ?

Thanks !

1 Like

You people and your cool toys.

Someone buy me automation studio so I can help:rofl:

2 Likes

string json = Newtonsoft.Json.JsonConvert.SerializeObject(obj);




var url = "recipe endpoint";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.Accept = "application/xml";
request.ContentType = "application/json";
request.Headers["api-token"] = "key";

using(var writer = new StreamWriter(request.GetRequestStream()))
    {       
      writer.Write(json); 
    }   
try {
  var response = (HttpWebResponse)request.GetResponse(); 
}
catch
{}
1 Like

Thank you @aosemwengie1, I just got it working and was about to tweak my code to post it here, easier than I thought once I figured out which REST classes were available in the .Net libraries Epicor provides

1 Like