I’ve updated the Rest Nuget Helpers below and added some new functionality so I figured I’d document i there for those that are using it.
Enhancements include CallContext Handling, Epicor Session Info and Specific License Type (Web Service License vs Default etc)
I have also deprecated most calls that aren’t the dynamic ones it just doesn’t make a lot of sense to have BO specific calls. So you should be using Dynamic Get, Post, Patch and Delete almost exclusively though the old calls still remain in the library (though deprecated)
1. License Type
When setting up the Epicor Rest Helper you can now specify the license type you’d like to consumme
EpicorRest.AppPoolHost = "yourdomain.yourhosting.tld";
EpicorRest.AppPoolInstance = "EpicorDemo10";
EpicorRest.UserName = "manager";
EpicorRest.Password = "manager";
EpicorRest.IgnoreCertErrors = true;
EpicorRest.License = EpicorLicenseType.WebService; // You can now specify the license type, it default to "Default" if not specified
EpicorRest.CallSettings = new CallSettings("EPIC03", string.Empty, string.Empty, string.Empty);
2. Call Context Support
You can now get and pass in CallContext (BPMData, and CallContextClient) with your requests. It is an optional parameter on all Dynamic calls (DynamicGet, DynamicPost, DynamicPatch, DynamicDelete)
You must pass an instance in, in order to get an instance back
EpicorRest.AppPoolHost = "yourdomain.yourhosting.tld";
EpicorRest.AppPoolInstance = "EpicorDemo10";
EpicorRest.UserName = "manager";
EpicorRest.Password = "manager";
EpicorRest.IgnoreCertErrors = true;
EpicorRest.License = EpicorLicenseType.WebService; // You can now specify the license type, it default to "Default" if not specified
EpicorRest.CallSettings = new CallSettings("EPIC03", string.Empty, string.Empty, string.Empty);
//Instanciate an Empty Call Context
CallContextHeader callContext = new CallContextHeader();
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("$filter", $"Key1 eq 'Larry-Top' and Key5 eq 'Larry-Top'");
dic.Add("$top", "1");
newObj = EpicorRest.DynamicGet("Ice.BO.UD01Svc", "UD01s", dic, null, callContext); //Pass Call Context in and it Updates in place with the response.
Console.WriteLine(callContext.Context.BpmData[0].Character01);
3. HttpStatus Codes
You can now also return the HTTPStatus code of each dynamic call simply (as with CallContext) instantiate a EpicorRestStatusCode and pass it in, the call with update the object with the call result.
EpicorRest.AppPoolHost = "yourdomain.yourhosting.tld";
EpicorRest.AppPoolInstance = "EpicorDemo10";
EpicorRest.UserName = "manager";
EpicorRest.Password = "manager";
EpicorRest.IgnoreCertErrors = true;
EpicorRest.License = EpicorLicenseType.WebService; // You can now specify the license type, it default to "Default" if not specified
EpicorRest.CallSettings = new CallSettings("EPIC03", string.Empty, string.Empty, string.Empty);
//Instanciate an Empty Call Context
CallContextHeader callContext = new CallContextHeader();
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("$filter", $"Key1 eq 'Larry-Top' and Key5 eq 'Larry-Top'");
dic.Add("$top", "1");
EpicorRestStatusCode statusCode = new EpicorRestStatusCode();
newObj = EpicorRest.DynamicGet("Ice.BO.UD01Svc", "UD01s", dic, statusCode , callContext); //Pass in an instance of status code and it will be returned to you for error checking.
if(statusCode.RestCallStatusCode == System.Net.HttpStatusCode.OK) //See SWAGGER for expected codes on each call
{
//Good!
}
else {
//Bad
}
4. Session Info
Up until now REST Calls have not carried session specific headers now if you want to use an actual session (server side) you can do so, simply wrap any of the REST calls in an EpicorSession instance and the session information will be passed to the server with each call, and it will be disposed Logged out when the using finishes.
EpicorRest.AppPoolHost = "yourdomain.yourhosting.tld";
EpicorRest.AppPoolInstance = "EpicorDemo10";
EpicorRest.UserName = "manager";
EpicorRest.Password = "manager";
EpicorRest.IgnoreCertErrors = true;
EpicorRest.License = EpicorLicenseType.WebService; // You can now specify the license type, it default to "Default" if not specified
EpicorRest.CallSettings = new CallSettings("EPIC03", string.Empty, string.Empty, string.Empty);
//Note you must setup the Rest Helper FIRST before instantiating a new EpicorSession
using (EpicorSession sess = new EpicorSession())
{
//The call below will carry a valid EpicorSession ID which can be monitored server side
Dictionary<string, string> dic = new Dictionary<string, string>();
dic.Add("$filter", $"Key1 eq 'Larry-Top' and Key5 eq 'Larry-Top'");
dic.Add("$top", "1");
newObj = EpicorRest.DynamicGet("Ice.BO.UD01Svc", "UD01s", dic, statusCode, c);
//Session info can be accessed via EpicorRest.EpiSession
Console.WriteLine(EpicorRest.EpiSession.SessionID);
}
Update 6/2/2020 Release 1.1.11
Fixes a potential memory leak issue where the RequestLogger kept every request forever on a long running application this caused a huge inflated memmory footprint and would eventually cause a stack overflow if not manually cleared.
In this version we limit the amount of requests in the RequestLog to 25 but this can be overwritten by setting the MaxRequestLogLength property
EpicorRest.MaxRequestLogLength = 900;