EMUG 2/21/2025 - REST and Functions Notes and Resources

Power Point Slides:
Epicor REST and Functions.pptx (3.4 MB)

Here are some of the resources and examples covered in the EMUG meeting for 2/21/2025 on the topic of REST and Epicor Functions.

Tools

Tool URL Purpose
Postman https://www.postman.com/ Free (as in beer) tool to exercise HTTP Verbs
Classic Trace Helper Trace Helper Utility for Epicor ERP 10 Utility to help you read / parse traces done in classic client
Kinetic Web Trace Utility Kinetic Trace Helper Utility 1.0 (Kinetic Web) Chrome Extension Chrome Extension to help you trace Epicor on the Web
REST Nuget Library Epicor Rest Helper (Nuget) Updated V3 C# Library to make calling and interacting with Epicor REST a breeze
NMP Node Rest Library Epicor Rest Helper for Node (npm) V1 Node Library to make interacting with Epicor Rest a breeze from Node
Angular Rest Library Epicor Rest Helper for Angular (NPM ) V1 Angular Library to make working with Epicor Rest and Angular easy
Excel with Params REST Pull REST data into Excel based on values on excel? - #24 by amurdock Amazing Excel tool by @amurdock which allows you to run REST BAQs directly from Excel while passing in dynamic parameters and filters.

Examples

C# Example for Calling an Epicor BAQ

using EpicorRestAPI;

EpicorRest restClient = new EpicorRest();
restClient.AppPoolHost = "your.epicor.server";
restClient.AppPoolInstance = "YourEpicorInstance";
restClient.UserName = "epicor"; //username for epicor
restClient.Password = "epicor"; //password for epicor
restClient.Company = "EPIC06"; //Your Company ID
restClient.CallSettings = new CallSettings("EPIC06", "MfgSys", "eng-us", "");
restClient.APIKey = "YourEpicorApiKeyGoesHere";

var baqResult =restClient.BaqGet("zCustomer01");

if(!baqResult.IsErrorResponse)
{
    Console.WriteLine(baqResult.ResponseBody);
}

Node Example

Calling a BAQ and spinning a web server that will execute ANY BAQ passed in to the URL as

localhost:3000/baq/<baqID>
import { EpicorRestService } from "epicor-rest-node";
import express from 'express';

let EpicorRestApi = new EpicorRestService();
EpicorRestApi.AppPoolHost = "Your.Epicor.Server";
EpicorRestApi.AppPoolInstance ="EpicorInstance";
EpicorRestApi.APIKey="YourEpicorKeyGoesHere";
EpicorRestApi.UserName="epicor"; //Your Epicor Username
EpicorRestApi.Password="epicor"// Your Epicor Password
EpicorRestApi.Company="EDU06"; //Your Epicor Company ID

//Execute BAQ and print the results
EpicorRestApi.BaqGet('zCustomer01')?.then((data:any) => {
    console.log(JSON.stringify(data.data, null, 2));
}).catch((error) => {
    console.log(error);
});

// Spin an Express Server and respond to any dynamic BAQ
const app = express();
const port = 3000;

app.get('/baq/:myBaq', async (req, res) => {
    const myBaq = req.params.myBaq;
    try {
        const data = await EpicorRestApi.BaqGet(myBaq);
        res.json(data?.data);
    } catch (error:any) {
        res.status(500).send(error?.message);
    }
});

app.listen(port, () => {
    console.log(`Server is running at http://localhost:${port}`);
});

Calling REST from a Classic Customization

You need to bring in these helper DLLs
image

Execute a Function in the Client using Rest Helper

var _restClient = new RestClientBuilder().UseSession(oTrans.CoreSession).Build();
		var functionContent = new RestContent(new { iPhrase = "hey There" });
		var functionResponse = _restClient.Function.Post("FunFunction", "MyHelloFunction", functionContent, published: false);
		var functionResult = functionResponse.GetAnonymousResult(new { oSuccess = false, oMessage = ""  });

		if(!functionResult.oSuccess)
		{
			MessageBox.Show(functionResult.oMessage);
		}
16 Likes

Great presentation today, Jose!

1 Like

Thanks Kevin
Rushed! too much content for 55 minutes

Damn, missed it… hoping the vid pops up somewhere :slight_smile: As always thanks for spending the time to put this stuff together Jose.

:beer:

It will be up on CodaBears YouTube channel by next week.

3 Likes