REST Calls in Infor Process Automation

 7 Replies
 3 Subscribed to this topic
 52 Subscribed to this forum
Sort:
Author
Messages
Ethan
Advanced Member
Posts: 28
Advanced Member

    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.

    David Williams
    Veteran Member
    Posts: 1127
    Veteran Member
      I'm doing something like this for an ICIMS interface using the WebRun node to execute my API calls. Processing the data you receive back depends on the format of that data. I'm getting JSON formatted data but you might get XML. If you're getting XML then you'll need to get examples and build a schema (if the vendor doesn't provide it) for parsing the XML data.
      David Williams
      Ethan
      Advanced Member
      Posts: 28
      Advanced Member

        Thanks David. We are working with the vendor trying to get the Webrun node setup.

        Scott Perrier
        Veteran Member
        Posts: 39
        Veteran Member
          We attempted a REST API using the Webrun node to connect with the Nuvia API. We encountered an issue with how they handle the secure connection within the API that Lawson nor our experts could resolve. We had to switch to a flat file trigger of the flow instead. The ION API connections will allow it but we do not have the enterprise product from Lawson yet.
          jamesraceson
          Veteran Member
          Posts: 52
          Veteran Member
            Ethan,

            We use REST API with a couple of our vendors. We are currently hosted and using IPD version 11.0.10. Some things I ran into during my trials and tribulations on making our interfaces work that may be helpful:

            • It shouldn’t be an issue now as most everyone is using the correct TLS version, but make sure your version is allowed with the vendor

            • Make sure the IP of your Landmark or other related servers are allowed through the vendors’ firewall. I know it might sound like a basic item, but you would be surprised how many times it is not set up.

            • Like David mentioned, if your return is XML make sure to use the correct/good schema (very important). If your return is JSON, you can use the JSON parser nodes in IPD. Once that is done, you can use the notation on the output from the node to find the information you need pretty easily (examples are in the good old PDF IPD user guide).

            • Check to see if there is a limit of how many calls per day or hour are allowed by your vendor. Most of the time, these limits are pretty high and you shouldn’t need to worry, but if you are doing some initial large updates you might need to put in a Wait node within a read loop so you don’t hit a limit.

            • Depending on the vendor and/or application you are working with, if you are using JSON sometimes you will not get back a “blank” field if there isn’t any data. This can be frustrating while you are testing and building because you will think something is wrong. If you are lucky enough to have a test/dev copy of the vendor’s data, the best way is to put something in every field so you can see what comes through the API.

            • Really check or get the specs from the vendor on the data fields you will be importing or pushing in to the PA52. Most of your development time will be spent on formatting. I ran into issues where the vendor’s fields allowed for more data then the fields I had to put into Infor Lawson. You will need to encounter for that and come up with a plan on what to do with the extra data.

            • Another one I found out the hard way is there were some fields on the online forms with the vendor application that did not have any data validation checks (i.e. only allow numerical digits in a number field, phone number formatting, etc.). This is an unfortunately reality, but will make for more overhead on your development design for sure.

            Best of luck to you and I hope you have a great tech resource with your vendor. That will make a huge difference when you are troubleshooting issues.
            Ethan
            Advanced Member
            Posts: 28
            Advanced Member

              Thank you everyone for your feedback. We've been muddling our way through the process. Quite a bit of trial and error.

              HDAustin13
              Advanced Member
              Posts: 31
              Advanced Member

                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

                 

                LauaLuau
                Basic Member
                Posts: 13
                Basic Member
                  I had to do this before support for REST in IPA was possible, basically, create a c# program in visual studio to handle the interaction, execute it and return the results in a System Command node. If I get a bad rc, I report the error text. Branch node in flow handles the return code. This is a lookup into the sam.gov website to see if a vendor is on the active exclusion list for grants.
                   
                  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);
                          }
                      }
                  }
                  
                  


                  That was the old one for the REST api in VS2010. Here's the latest one using SOAP (VS2017):
                   
                  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);
                          }
                      }
                  }