REST - Receiving data in an Epicor function from an external webhook

You can work with structured JSON directly in EFs and many other customizable parts of Epicor. Add a reference to Newtonsoft.Json and parse your parameter as a dynamic object. You won’t be able to pass the resulting object around, but you’ll be able to work with its keys and subkeys in custom code. I’ve used this technique to pass JSON configuration to no-inputs configurators via UD tables.

Your example JSON is a single object, so parsing would look like this:

If your JSON were an array, it would look like this:

But I agree with @Mark_Wonsil about the need for history and replayability. Either configure the web service to drop files in a hot folder instead of hitting a URI, or write your own middleware to receive the JSON and save it. From there, whether the middleware or your EF parses the JSON probably depends on whether Epicor needs the whole structure or just a couple things from it. Also keep in mind that with dynamic, you lose a lot of compile time safety. If you try to access a non-existent property or treat it as the wrong type, it will blow up at runtime. It may be easier/better to handle these kinds of errors in middleware.

2 Likes