Passing Data to Epicor Function from External API Call

If an Epicor function is called externally (as a REST API Endpoint), how can the function read the JSON packet that has been passed to it?

I’ve searched high and low, and I can only find how to access JSON data from an outbound API call response values.

For context, I am trying to send data to an Epicor function that uses logic to update/create entries. I find this to be more scalable for my company than making multiple API calls from our web app.

You would receive it as a string and then parse it into a dynamic variable. Like:

REST - Receiving data in an Epicor function from an external webhook - ERP 10 - Epicor User Help Forum (epiusers.help)

1 Like

Using the below code block as an example, my main issue is what to replace the "{number:1000, str:'string', array: [1,2,3,4,5,6]}" argument within the JObject.Parse method with.

dynamic d = JObject.Parse("{number:1000, str:'string', array: [1,2,3,4,5,6]}");

Console.WriteLine(d.number);
Console.WriteLine(d.str);
Console.WriteLine(d.array.Count);

Does anyone know the correct argument(s) to represent the content of the API call?

I used the second answer on that StackOverflow page and it worked for me.

dynamic d = JsonConvert.DeserializeObject("{\"message\":\"Hi\"}");

See if that works better for you.

2 Likes

That’s going to depend on what you’re actually passing into the function.

If you can give me the signature for your function and an example of what you’re passing to it, I should be able to give you some code examples that will work for your specific case.

The input of the function would be the Json packet which looks something like this:

{
    "orderName": "Test Order",
    "customerID": "003",
    "lineItems":  [
        "900023-003",
        "900043-001"
    ],
    "quantity": [
        "2",
        "3"
    ],
    "unitCost": [
        "45.60",
        "53.31"
    ]
}

And the output would be to create/update a Quote in Epicor. Return value is Epicor Order ID.

Thanks! I will try this and mark it as the solution if/when it works to make sure it works with my version.

Aaron’s given us a very good example in this link, hopefully that helps:
Rest API V2 Batch Post - Help Needed - ERP 10 - Epicor User Help Forum (epiusers.help)

1 Like