AnsweredAssumed Answered

Calling a boomi process from C# WebApp is not working. I get a 503 error.

Question asked by mark.easton291228 on Jan 23, 2018
Latest reply on Jan 23, 2018 by mark.easton291228

In the exception I see: "You have exceeded the alloted number of API calls for your account for a twenty four hour period". We are using Dell Boomi for the first time and have setup a simple process in Boomi and then coded for that to be called from Our App (using a locally installed Atom for testing). Is the problem because we just have a Trial a/c which I have seen suggested? Or is there some other issue? The code is this:

    public class Boomi : IBoomi
    {
        private readonly IFlowinglyLog _log;
        private string _userName;
        private string _userPassword;
        private string _accountId;
        private string _atomId;
        private string _processId;

        public Boomi(IFlowinglyLoggingService loggingService)
        {
            _log = loggingService.GetLogger(GetType());
        }

        public void ConfigBoomi(string userName, string userPassword)
        {
            _userName = userName;
            _userPassword = userPassword;
        }

        public void ConfigProcess(string accountId, string atomId, string processId)
        {
            _accountId = accountId;
            _atomId = atomId;
            _processId = processId;
        }


        public BoomiResult LookupCity(string city = "Auckland")
        {
            var result = new BoomiResult {ResultCode = "500"};
            try
            {
                //Ref: http://help.boomi.com/atomsphere/GUID-EE8C69C1-CBAF-4FC2-9470-F21043D19BAF.html

                const string postDataTemplate = "<ProcessExecutionRequest processId=\"{0}\" atomId=\"{1}\" xmlns=\"http://api.platform.boomi.com/\">{2}</ProcessExecutionRequest>";
                var processProps = "<ProcessProperties><ProcessProperty><Name>City</Name><Value>" + city +
                                   "</Value></ProcessProperty></ProcessProperties>";
                var postData = string.Format(postDataTemplate, _processId, _atomId, processProps);
                var authInfo = _userName + ":" + _userPassword;

                var request = WebRequest.Create("https://api.boomi.com/api/rest/v1/" + _accountId + @"/executeProcess");
                request.Method = "POST";
                var byteArray = Encoding.UTF8.GetBytes(postData);
                request.ContentType = "application/xml";
                request.ContentLength = byteArray.Length;
                authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
                request.Headers["Authorization"] = "Basic " + authInfo;

                using (var dataStream = request.GetRequestStream())
                {
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    dataStream.Close();
                    using (var response = request.GetResponse())
                    {
                        result.ResultCode = ((HttpWebResponse)response).StatusDescription;
                        using (var s = response.GetResponseStream())
                        {
                            using (var reader = new StreamReader(s))
                            {
                                var r = reader.ReadToEnd();
                                _log.Info(
                                    $"Successfully started Boomi Process {_processId} on Atom {_atomId} with Account ID {_accountId}\r\nFor city: {city}\r\nHTTP Response: {result}\r\n" +
                                           (string.IsNullOrWhiteSpace(r) ? "" : "Result: " + r));
                                result.ResultValue = r;
                                return result;
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error(
                    $"Failed to start Boomi Process {_processId} on Atom {_atomId} with Account ID {_accountId}\r\nHTTP Response: {result}\r\nError: {e}");
            }
            return result;
        }
    }

Outcomes