Jose, got farther this time, but now getting this error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
HResult=0x80131500
Message=Cannot perform runtime binding on a null reference
Source=System.Linq.Expressions
StackTrace:
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at EpicorRestAPI.EpicorRestSession…ctor()
at APOCInvoiceLoad.Program.CallPostFunctionNew() in M:\IT_Volume\SourceCode\CSharp_102700\APOCInvoiceLoad\APOCInvoiceLoad\Program.cs:line 1562
at APOCInvoiceLoad.Program.CreateAPInvoiceBatch(String originalFile) in M:\IT_Volume\SourceCode\CSharp_102700\APOCInvoiceLoad\APOCInvoiceLoad\Program.cs:line 1200
This exception was originally thrown at this call stack:
[External Code]
APOCInvoiceLoad.Program.CallPostFunctionNew() in Program.cs
APOCInvoiceLoad.Program.CreateAPInvoiceBatch(string) in Program.cs
Error is occurring at the point of creating a new EpicorRestSession. Current code is below:
private static void CallPostFunctionNew()
{
EpicorRest.AppPoolHost = "usaz1app008p.am.dir.grpleg.com";
if (_ServerID == "")
EpicorRest.AppPoolInstance = "EpicorERP";
else
EpicorRest.AppPoolInstance = _ServerID;
EpicorRest.UserName = Properties.Settings.Default.BatchEntryPerson;
EpicorRest.Password = Properties.Settings.Default.BatchEntryPass;
EpicorRest.APIKey = EnvAPIKey;
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());
}
}
It worked just fine for me, Only thing I can think of is some of your settings are wrong… BUt that’s harad to troubleshoot without having your settings.
here’s a github project
that has a WORKING example of this API all you need to d is adjust the settings. I just tested it and worked like a dream.
Downloaded the project as a Zip file, unzipped it and opened the project. When I opened it, it apparently didn’t recognize it had a reference to the EpicorRestHelper DLL. I did look at the settings in the program.cs file, and mine only lacked the Timeout and MaxRequestLogLength properties. I’ll try the example and my project tomorrow, may attach my settings file if I’m still having issues.
I’m using the APIKeyPilot value in the program at the moment, and verified it’s correct. How can I get around the SSL issue? I have the certificate for the AppPoolHost installed on my system.
Value I’m using for the AppPoolHost property is just the FQDN of the server, no HTTPS:// on it. The AppPoolInstance value should be the app pool name, right? not like “net.tcp:///”, correct?
Then this doesn’t make any sense… I’m doind exactly what you’ve suggested and still getting the error. I’ even have the IgnoreCertErrors property = true.
I’ve been trying the RestExample project over the past few minutes with my parameters and trying to run the zCustomers01 BAQ, then one of my own. I’m getting back a 404 error in the ResponseBody:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>404 - File or directory not found.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;}
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;}
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
<div class="content-container"><fieldset>
<h2>404 - File or directory not found.</h2>
<h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
</fieldset></div>
</div>
</body>
</html>
Jose, could any of these issues I’m having be related to the Epicor version I’m on? We’re still on 10.2.700.21. Also, I haven’t tried PostMan recently, I’ve been using the V2 Help pages to run the function.
Jose, I apologize for taking so long to get back to you, I was on vacation Friday thru Monday. I got Postman working with the help of a colleague, but I’m still getting a 401 error when attempting the POST call:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
<style type="text/css">
<!--
body {
margin: 0;
… <h3>You do not have permission to view this directory or page using the credentials that you supplied.
</h3>
</fieldset>
</div>
</div>
</body>
</html>