We are working on a new interface where the vendor provided a REST API. Is it possible to interact with a REST API through an Infor Process Automation? We typically deal with flat files, this is our first project using the REST API. We will basically need to pull some data through the API, do an AGS call to load the data into a PA52 action, and then post some data back through the REST API. Any guidance would be appreciated.
Thanks David. We are working with the vendor trying to get the Webrun node setup.
Thank you everyone for your feedback. We've been muddling our way through the process. Quite a bit of trial and error.
Hello everyone and thanks for this post and its answers.
I am working on a project like this which requires to call an API to process the data from the vendor but get stuck on how to start in IPD as it requires to use the token to the log to the API.
Does anyone has a sample available, can you please share it here so I can learn on how to do that.
Thanks in advance,
Han
using System; using System.Collections.Generic; using System.Linq; using System.Text; using SAMWSearch.SAMWS1; using RestSharp; namespace SAMWSearch { public class SAMResult { SAMWS1.ExclusionSearchResultType value { get; set; } } public class SamResults : List { } class Program { static int Main(string[] args) { var client = new RestClient("https://gw.sam.gov/SAMWS/1.0/ExclusionSearch"); var request = new RestRequest("doSearch", Method.POST); request.AddParameter("partialName", args[1]); var results = client.Execute(request); int result = 999; // 999 = error lookup not performed. 1 - Business excluded, 0 - Business not excluded Console.WriteLine("results"); result = 1; return (result); } } }
using System; using System.ServiceModel; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Xml; using System.IO; using System.Xml.Serialization; using System.Net; using System.Timers; using System.Threading; namespace SAMsearch { class Program { const int C_NOT_EXCLUDED = 0; const int C_EXCLUDED = 1; const int C_LOOKUP_NOT_PERFORMED = 999; /// /// Execute a Soap WebService call /// public static int Execute(string parm) { int result = C_LOOKUP_NOT_PERFORMED; // 1 - Excluded, Do Not Award Contract without first doing manual lookup. HttpWebRequest request = CreateWebRequest(); XmlDocument soapEnvelopeXml = new XmlDocument(); string xml = @" "; xml = xml + parm; xml = xml + @" "; // JOE* ALLEN* GORDON* //BEST BUY soapEnvelopeXml.LoadXml(xml); using (Stream stream = request.GetRequestStream()) { soapEnvelopeXml.Save(stream); } using (WebResponse response = request.GetResponse()) { using (StreamReader rd = new StreamReader(response.GetResponseStream())) { string soapResult = rd.ReadToEnd(); Console.WriteLine(soapResult); // If the following string is included in the response, the company is not exluded. int index = soapResult.IndexOf("No records foundtrue"); if (index < 0) { result = C_EXCLUDED; } else { result = C_NOT_EXCLUDED; } } } return (result); } /// /// Create a soap webrequest to [Url] /// /// public static HttpWebRequest CreateWebRequest() { HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(@"https://gw.sam.gov/SAMWS/1.0/ExclusionSearch"); webRequest.Headers.Add(@"SOAP:Action"); webRequest.ContentType = "text/xml;charset=\"utf-8\""; webRequest.Accept = "text/xml"; webRequest.Method = "POST"; return webRequest; } public static void help() { Console.WriteLine("SAM90W: No business name specified."); // Console.ReadKey(); Console.WriteLine("SAM01I: Information"); Console.WriteLine(" Purpose: Looks up a business name in the SAM Exclusion List at gw.sam.gov."); Console.WriteLine(" Prints results and returns a code: 0 = Not Excluded, 1 = Not Excluded,"); Console.WriteLine(" or 999=Lookup not performed with error messages printed.\n"); Console.WriteLine(" Format: SAMsearch [Business Name]\n"); Console.WriteLine(" Example: SAMsearch \"JOE ALLEN GORDON\""); Console.WriteLine(" on 2/20/2014 this returns 1 = excluded.\n"); Console.WriteLine(" Example2: SAMsearch \"JOE GORDON\""); Console.WriteLine(" on 2/20/2014 this also returns 1 = excluded.\n"); Console.WriteLine(" Example3: SAMsearch \"JOE MARTIN GORDON\""); Console.WriteLine(" on 2/20/2014 this returns 0 = not excluded.\n"); } static int Main(string[] args) { int result = 999; // 999 err - lookup not performed. 1 - Business excluded: do not award, 0 - Business not excluded. Console.WriteLine("SAMsearch 2.1 2/11/2015."); if ( args.Length > 0) { if (args[0].Length > 0) { string parm_company_name = args[0].ToUpper(); parm_company_name = parm_company_name.Replace("&", "&"); parm_company_name = parm_company_name.Replace("<", "<"); parm_company_name = parm_company_name.Replace(">", ">"); parm_company_name = parm_company_name.Replace("'", "'"); parm_company_name = parm_company_name.Replace("\"", """); Console.WriteLine("SAM03I Looking up: '{0}' in SAM EPLS.EPLS.", parm_company_name); result = Execute(parm_company_name); } else { help(); } } else { help(); } return (result); } } }