I just switched over to using @josecgomez 's new package for .NET 6, and I’m getting the attached errors when trying to instantiate a new EpicorRestSession. Code is below:
using (EpicorRestSession ses = new EpicorRestSession())
{
EpicorRest.AppPoolHost = "https://usaz1app008p.am.dir.grpleg.com";
EpicorRest.AppPoolInstance = "EpicorERPPilot";
EpicorRest.UserName = Properties.Settings.Default.BatchEntryPerson;
EpicorRest.Password = Properties.Settings.Default.BatchEntryPass;
EpicorRest.APIKey = Properties.Settings.Default.APIKey;
EpicorRest.Company = Properties.Settings.Default.CompanyID;
EpicorRest.APIVersion = EpicorRestVersion.V2;
EpicorRest.License = EpicorLicenseType.Default;
var smsSend = new
{
GroupID = $@"{BatchGroupID}"
};
var rsp = EpicorRest.EfxPost(Properties.Settings.Default.RESTLibrary, Properties.Settings.Default.RESTFunction, smsSend);
if (rsp.IsErrorResponse)
Console.WriteLine(rsp.ResponseError.ToString());
}
I apologize, the errors came up before adding https:// to the creation. Question: Should the AppPoolHost property have the entire endpoint, or just the server name? Thing actually fails in debug as soon as the EpicorRestSession call executes…
Jose, below is the code I currently have in my program. It’s throwing an exception as soon as the EpicorRestSession object is created. What am I missing?
private static void CallPostFunctionNew()
{
EpicorRest.AppPoolHost = "(server FQDN)";
if (_ServerID == "")
EpicorRest.AppPoolInstance = "EpicorERP";
else
EpicorRest.AppPoolInstance = _ServerID;
EpicorRest.UserName = Properties.Settings.Default.BatchEntryPerson;
EpicorRest.Password = Properties.Settings.Default.BatchEntryPass;
EpicorRest.APIKey = Properties.Settings.Default.APIKey;
EpicorRest.Company = Properties.Settings.Default.CompanyID;
EpicorRest.APIVersion = EpicorRestVersion.V2;
EpicorRest.License = EpicorLicenseType.Default;
EpicorRest.IgnoreCertErrors = true;
using (EpicorRestSession ses = new EpicorRestSession())
{
var smsSend = new
{
GroupID = $@"{BatchGroupID}"
};
var rsp = EpicorRest.EfxPost(Properties.Settings.Default.RESTLibrary, Properties.Settings.Default.RESTFunction, smsSend);
if (rsp.IsErrorResponse)
Console.WriteLine(rsp.ResponseError.ToString());
}
}
Jose, here’s the error:
System.MissingMethodException
HResult=0x80131513
Message=Method not found: 'Void RestSharp.RestClient…ctor(RestSharp.RestClientOptions, System.Action1<System.Net.Http.Headers.HttpRequestHeaders>)'. Source=EpicorRESTAPICore StackTrace: at EpicorRestAPI.EpicorRest.HttpJson(Method iMethodType, String iBaseMethodURl, String iFormattedParams, Object iJsonData, CallContextHeader iCallContext, Dictionary2 requestHeaders)
at System.Dynamic.UpdateDelegates.UpdateAndExecute6[T0,T1,T2,T3,T4,T5,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5)
at EpicorRestAPI.EpicorRest.BoPost(String iBO, String iMethod, Object iData, CallContextHeader iCallContext)
at EpicorRestAPI.EpicorRestSession…ctor()
at APOCInvoiceLoad.Program.CallPostFunctionNew() in M:\IT_Volume\SourceCode\CSharp_102700\APOCInvoiceLoad\APOCInvoiceLoad\Program.cs:line 1427
at APOCInvoiceLoad.Program.CreateAPInvoiceBatch(String originalFile) in M:\IT_Volume\SourceCode\CSharp_102700\APOCInvoiceLoad\APOCInvoiceLoad\Program.cs:line 1084
This exception was originally thrown at this call stack:
[External Code]
APOCInvoiceLoad.Program.CallPostFunctionNew() in Program.cs
APOCInvoiceLoad.Program.CreateAPInvoiceBatch(string) in Program.cs
Jose, I retargeted the project to .NET Core 3.1, however EpicorRESTAPICore now shows an error saying the type or namespace cannot be found. I have the NuGet package installed, what could I still be missing?
If your project is targeting .NET 6 you should use version 2.2.0.2 of the library which should automatically install Newtonsoft 13.0.2 and RestSharp 108.0.3