Epicor Rest Helper (Nuget) Updated (1.1.11)

I can compile with an older version of .net… just not sure what version is “best”…
It is currently compiled with 4.6.1 which is fairly old. Not sure if going back to 4.5 is worth it.

I wouldn’t bother - its not like you have a legacy user base you have to keep happy. In this case @JMyers56 was able to change his project target anyway.

1 Like

@josecgomez … we’re not currently specifying any session data in our calls to the API. Are there any advantages to using that feature considering we are Epicor Cloud?

Hi @Jeff_Owens
That allows you to see server side the Session and address it , change it, etc using BPMs and such. It also gives you control of when the session is disposed etc can help with licensing

1 Like

I’m having trouble with EpicorRest.GetBAQResults - I get the following error:

Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: <. Path '', line 0, position 0.'

I used GetBAQResultJSON to get the Json, and put it in an online validator, which says it is valid. However I noticed that the JSON from GetBAQResultJSON is still escaped:

"{\r\n  \"odata.metadata\":\"https://ausmtsapp01.epicorsaas.com/SaaS203/api/v1/BaqSvc/OEMSpecsMachineInfo/$metadata#Epicor.DynamicQuery.QueryResults\",\"value\":[\r\n    {\r\n      \"UD100_Key1\":\"\",\"UD100_Key2\":\"\",\"UD100_Key3\":\"\",\"UD100_Key4\":\"\",\"UD100_Key5\":\"\",\"UD100_Character10\":\"1f7a6678-2884-4baf-a30d-67987d6150d0\",\"UD100_Number01\":\"0.000000000\",\"UD100_Number02\":\"0.000000000\",\"UD100_Number03\":\"0.000000000\",\"UD100_Number04\":\"0.000000000\",\"UD100_Number05\":\"0.000000000\",\"UD100_CheckBox01\":false,\"UD100_Date01\":null,\"UD100_Character01\":\"\",\"UD39_CheckBox03\":null,\"UD40_CheckBox01\":null,\"UD40_CheckBox02\":null,\"UD40_ShortChar12\":null,\"UD40_ShortChar13\":null,\"UD39_ShortChar09\":null,\"Calculated_Compare\":false,\"Calculated_Nom\":\"0X0\",\"RowMod\":null,\"RowIdent\":\"41f8bade-6aaf-4be2-b3bb-e97db237626f\",\"SysRowID\":\"41f8bade-6aaf-4be2-b3bb-e97db237626f\"\r\n    },{\r\n      \"UD100_Key1\":\"Astec\",\"UD100_Key2\":\"5X12\",\"UD100_Key3\":\"Bottom\",\"UD100_Key4\":\"6x5\",\"UD100_Key5\":\"(Discharge Panel)\",\"UD100_Character10\":\"D0E3B38A-3032-430A-B411-97E900C787B3\",\"UD100_Number01\":\"6.000000000\",\"UD100_Number02\":\"5.000000000\",\"UD100_Number03\":\"6.000000000\",\"UD100_Number04\":\"5.000000000\",\"UD100_Number05\":\"1.000000000\",\"UD100_CheckBox01\":true,\"UD100_Date01\":\"2019-08-21T00:00:00\",\"UD100_Character01\":\"This specification is missing the following information: Crown\",\"UD39_CheckBox03\":false,\"UD40_CheckBox01\":false,\"UD40_CheckBox02\":false,\"UD40_ShortChar12\":\"Approved\",\"UD40_ShortChar13\":\"Approved\",\"UD39_ShortChar09\":\"Incomplete\",\"Calculated_Compare\":false,\"Calculated_Nom\":\"6X5\",\"RowMod\":null,\"RowIdent\":\"f8cbe1a7-3ef6-4161-8f13-e876610c5eae\",\"SysRowID\":\"f8cbe1a7-3ef6-4161-8f13-e876610c5eae\"\r\n    },{\r\n      \"UD100_Key1\":\"Astec\",\"UD100_Key2\":\"5X12\",\"UD100_Key3\":\"Bottom\",\"UD100_Key4\":\"6x5\",\"UD100_Key5\":\"(Feed Panel)\",\"UD100_Character10\":\"48F31B64-BB4B-4D3C-A2A4-B2A9C3E96876\",\"UD100_Number01\":\"6.000000000\",\"UD100_Number02\":\"5.000000000\",\"UD100_Number03\":\"6.000000000\",\"UD100_Number04\":\"5.000000000\",\"UD100_Number05\":\"1.000000000\", **<snip>**

I think that is probably the issue. Not sure if it started happening because I updated the Rest helper nuget package or if it was the last Epicor update we got… I think it needs to be double parsed.

@josecgomez Any chance you can publish these helpers to Github?

1 Like

Most of these are deprecated @Evan_Purdy can you try using GetDynamic instead?
And let me know what you get? (no pun intended)

Seems to work, I will have to change my code as it kind of assumed a datatable and not a JObject or whatever that is returning. I didn’t realize the other methods were deprecated - maybe add the ObsoleteAttribute :stuck_out_tongue:

I did to most lol forgot this one

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;
1 Like

Note that this will very likely be the last release of the NuGet at v1. Our next release is intended to include v2 and backwards compatibility for v1. We intend to do a rewrite so there will very likely be breaking changes from our current v1 especially in regards to error handling, we intend to improve it greatly. We are aiming to keep signatures as much the same as we can and remove all deprecated methods that were originally very BO specific before the generalized methods were implemented.

2 Likes

@josecgomez, @jgiese.wci
Is there documentation for these nuget packages and maybe some examples? I am messing around with them and am not getting very far.

The OP Above has a bunch of examples. What are you not getting to work?

Just trying this simple call and i get a null ref at the DynamicGet.

EpicorRest.AppPoolHost = "https://site";
EpicorRest.AppPoolInstance = "EpicorTrain10";
EpicorRest.UserName = "manager";
EpicorRest.Password = "manager";
EpicorRest.IgnoreCertErrors = true;
EpicorRest.License = EpicorLicenseType.Default; // You can now specify the license type, it default to "Default" if not specified
EpicorRest.CallSettings = new CallSettings("EPIC06", 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("$top", "1");

var newObj = EpicorRest.DynamicGet("Erp.BO.CustomerSvc", "Customers", dic);

No HTTPS in the Host.

no change.

PM me your settings as they are
Also what version of Epicor ?

Had to remove http:// or https:// altogether from the AppPoolHost property, then it worked.

Thanks @josecgomez!

1 Like

@josecgomez
Is there any simpler way to do this with your nuget without having to add the parameters one by one?

Dictionary<string, string> laborDic = new Dictionary<string, string>();
laborDic.Add("whereClauseLaborHed", "EmployeeNum = '" + id +"' and ActiveTrans = yes BY PayrollDate");
laborDic.Add("whereClauseLaborDtl", "EmployeeNum = '" + id + "' and ActiveTrans = yes");
laborDic.Add("whereClauseLaborDtlAttch", "");
laborDic.Add("whereClauseLaborDtlComment", "");
laborDic.Add("whereClauseLaborEquip", "");
laborDic.Add("whereClauseLaborPart", "");
laborDic.Add("whereClauseLbrScrapSerialNumbers", "");
laborDic.Add("whereClauseLaborDtlGroup", "");
laborDic.Add("whereClauseSelectedSerialNumbers", "");
laborDic.Add("whereClauseSNFormat", "");
laborDic.Add("whereClauseTimeWeeklyView", "");
laborDic.Add("whereClauseTimeWorkHours", "");
laborDic.Add("pageSize", "0");
laborDic.Add("absolutePage", "0");

JObject laborDetails = EpicorRest.DynamicPost("Erp.BO.LaborSvc", "GetRows", laborDic);

If the where clause is empty maybe try not adding it to the dictionary and see if it works.

I tried doing that. they are required.