I’m trying to update few UD fields (one string, one int and three datetime) for AP Invoice using Erp.BO.APInvoiceSvc - APInvoices(‘{Company}’,{VendorNum},‘{InvoiceNum}’).
I’m using EpicorRestAPICore package (great work - thanks for sharing!) and BOPatchAsync funtion.
Everything works fine on 2025.1.6 (Epicor Demo). But when I try to run it on Client Pilot on 2023.2.31, then I get error message: Length cannot be less than zero. (Parameter ‘length’). However, if i try to post the same data via RestHelp, it works.
I don’t have any field named length, so I think it is something about the size of some array or nobody-know-what. What could be the reason of that?
There is a known issue with updating datetime fields in Epicor’s V2 API. We got around it by using the less secure V1 API for updating those datetime fields and V2 for everything else.
I think it’s not the case here, because it works with v2 in RestHelp.
I would put it in a function and then call the function, rather than the BO directly.
You can then test through Swagger and add debug message if requird.
How you can execute function via RestAPI?
Anyway it seems to me a little bit weired to create additional function which will call BO, instead of calling BO directly. But who knows?
It’s covered in the REST Technical Reference guides.
Honestly, it’s a much better practice to call functions instead of calling the business objects directly:
- The REST endpoints are generic wrappers around the business objects, so they will include more overhead than a custom function.
- Calling the REST endpoints directly tightly couples your client to Epicor code making upgrades more brittle. You will potentially need to update each client on an upgrade where a function encapsulates the changes. Fix the function at the server and all your clients run without even knowing there was a change.
- You have better error handling within functions, and you keep that error handling out of your client code.
- You can reduce the number of calls over the wire by making multiple business object calls in a single function call.
- Your payloads will be smaller than the generic REST endpoint
- You have control of the function signature to make it easier for the client to consume.
- You can shape the data that better suits your client.
Thank’s for detailed explanation. Need to check this path.