Are Epicor REST C# types available?

Hello,

I have been extensively reviewing Epicor REST Integration examples and noticed that they are all using anonymous object types to interact with the API. Does anyone have any input regarding using strongly-typed objects instead when interacting with the API? This would greatly benefit integrators such as myself who would rather provide and receive a strongly-typed object to/from the API (e.g. doing a GET against Erp.Bo.SalesRepSvc returns a JSON body that can be deserialized into a “SalesRepRow” type), but currently it’s up to the integrator to create these types.

The closest thing I’ve found to what I’m after is within these Nuget packages by Jose Gomez but they only seem to include a couple object types unless I’m missing something: NuGet Gallery | josecgomez

Ideally Epicor would provide the complete collection of C# types (or the complete API wrapper) as a Nuget package so integrators can dive right in to API interaction without having to worry about generating the types.

Here’s an example I’ve written using strongly-typed objects generated using a REST generator I’ve adapted from Ed Welsh (GitHub - martin-technology-group/EpicorRESTClientGenerator)

public class SalesReps : ICRUDAsync<SalesRepRow, string>
{
    private ErpBOSalesRepSvc SalesRepService { get; set; }


    public SalesReps()
    {
        SalesRepService = new ErpBOSalesRepSvc();
    }


    public async Task<SalesRepRow> Create(SalesRepRow salesRep)
    {
        if (string.IsNullOrWhiteSpace(salesRep.Company))
        {
            salesRep.Company = "Denmar";
        }


        return await SalesRepService.SalesRepsAsync(salesRep);
    }


    public async Task<SalesRepRow> Read(string salesRepCode)
    {
        return await SalesRepService.GetById_SalesRepAsync("Denmar", salesRepCode, null, null, null);
    }


    public async Task<ODataSetResponseOfListOfSalesRepRow> ReadMany(string select = null,
        string expand = null, string filter = null, string orderby = null, string top = null, string skip = null)
    {
        return await SalesRepService.GetRows_SalesRepsAsync(select, expand, filter, orderby, top, skip);
    }


    public async Task Update(SalesRepRow salesRep)
    {
        await SalesRepService.UpdateExt_SalesRepAsync("Denmar", salesRep.SalesRepCode, salesRep);
    }


    public async Task Delete(string salesRepCode)
    {
        await SalesRepService.DeleteUpdateExt_SalesRepAsync("Denmar", salesRepCode);
    }
}

Thanks for your time!

I found a tip somewhere that if you copy the JSON object from the Swagger interface, then in Visual Studio (I’m using 2017 Professional, in case it matters) you can use Edit > Paste Special > Paste JSON as Classes. It’s a quick means to an end.

Yeah sorry that Nuget I created and put out there I enhance it as I use it, but it won’t include all the objects. (sorry)
However you can easily create the objects in C# using the Paste -> Special -> JSON As Class into your visual studio project. The reason why Epicor won’t publish these objects is because with the user defined fields these objects are going to be unique to each customer.

I use dynamic a lot which allows you to use a “trust me compiler” approach to working with these objects. You can do things like

dynamic myOrder = JsonConvert.DeserilizeObject(jsonString);
myOrder.value[0].OrderNum = 4;

without having to create the Strongly Typed Order object. (You do lose auto complete though).

1 Like

Thank you Jose, I appreciate those tips. I thought that might be the answer but just wanted to make sure I wasn’t missing something. Thanks for your time!

1 Like