Rest API $orderby error in some services

I’m having an issue adding parameters for API calls only on some tables/services, hoping someone here can give me a clue of what’s going on, my problem is:

I can do this command and it works fine:
https://myServer/api/v2/odata/myCompany/Erp.Bo.QuoteSvc/Quotes?$select=QuoteNum&$orderby=QuoteNum desc

I can do this command and it also works more or less okay
but for some reason doesn’t return all results unless i also add $top=999999:
https://myServer/api/v2/odata/myCompany/Erp.Bo.QuoteSvc/QuoteDtls?$select=QuoteNum

According to the docs, I should be able to do this command:
https://myServer/api/v2/odata/myCompany/Erp.Bo.QuoteSvc/QuoteDtls?$select=QuoteNum&$orderby=QuoteNum desc

But I get this error:
Sorry Something went wrong. Please contact your system administrator. Correlation Id: xxxxxxxxxxxx

I’ve tried this within the epicor api help site, through postman, and through my own app in C#, same result.

Any ideas?

Best regards,

Rodrigo

welcome jurassic park GIF

Ok, question time :rofl:

Is there a particular reason you are using the straight odata calls? What business problem are you trying to solve.

Many ways to get data in Epicor, let’s find you the right one.

Hi there, thanks for answering.

I’m building a custom application within our CAD system that generates quotes for our projects. I want to push the quote and quote lines into Epicor.

I’ve done simpler ones so far and it works great, the issue came about when accessing the QuoteDtls and QuoteQties table.

Well my default answer is always going to be call a function or a baq instead, but failing that, use the custom methods, not the odata. The odata has some quirks.

2 Likes

Thanks this definitely gives me something to think about, as far as I understood this was the way to call the actual methods just from reading the docs on the API help website:

I feel like I’m missing something, what is it?

Yeah about the BAQ, I can also use that if needed, but I would think that for something simple like this a “standard” service was the best option.

But now you’ve made me think this is not the “standard” service haha.

custommethods2

Edit: Removed my company info lol.

100% best way to learn how to do something in Epicor, is first search here.
99.99175% next best way is to learn how to do tracing, in both the classic and web clients.

Lol why would they make the other one not the default.

Also custom methods sounds a lot more well… “custom” than “data” and “getrows”.

Thanks this does help a lot, I’m going to play around with it for a bit.

No problem bud. Hang out. This place is great in general, and a massive resource.

1 Like

The BAQ is far more powerful than the standard services. You can reduce the number of columns returned, reduce the number of rows returned, use calculated fields to make your data views easier to work with in UI, parameterize your selections, they’re easier to maintain, etc.

Yeah BAQs do have some nice things, but for something like quote creation, just sending a POST to the QuotesSvc/Quotes did seem like a nice choice, I was then able to add anything else I needed through a similar service.

Now I’m looking at those Custom methods @klincecum suggested, the GetRows seems like a pain in the sense that it needs all those whereClauses to filled in or empty, also no filters, sorting, selecting that I can see

But it does seem to return the full quote as a nested json object, not ideal but I can live with it.

Then calling all those little methods to add QuoteDtls, QuoteQties honestly sounds doable but a bit of a pain.

I’m back to thinking I’m missing something
Let me try to re-state my issue:
In the context of a standalone C# application, on windows, visual studio. What is the “standard” way to GET and POST data to/from Epicor?

The methods under oData where honestly working really well, and I had the entire application pretty much mapped out, until I got to the really weird issue on my first post, which again, only seems to happen in QuoteDtls and QuoteQties, not on QuoteHed

Write that crap in a function using the business objects and call that from your app.

bam yes GIF

1 Like

Sure seems like it, until you realize that you’re making several calls over the wire, the client needs to know how to react to each call, changes in the business object have to be reconciled during upgrades.

Its A Trap GIF by Star Wars

Or, follow Kevin’s advice and wrap the whole transaction in a function, make a single atomic call, and potentially make your upgrades easier. :person_shrugging: If you search the list, you will find many people struggling with the same issues as you are and then suddenly, the light hits them.

I see I see, am I mistaken in thinking that is a more “Epicor centered” approach (by function you mean an Epicor function right?)

I think I know what you mean, I’ve been thinking about it the other way, almost just interacting with with the data tables directly (through the oData services)

Could I trouble you for a link showing how to make an Epicor function?

Just to avoid me logging into EpicWeb and spending a couple of hours reading pdfs, that may or may not be the right ones, this is how I got to the REST api and oData stuff by the way.

Just so you get an idea of my epicor knowledge level, I know how to create and use relatively simple BAQs, make calls to the rest api from outside, add custom columns to tables and that is about it.

I’m way more comfortable “outside” epicor and I think that’s why I was basically using it as a data in / data out system.

Understandable. But learning the tooling will make your life MUCH easier.

In this thread here, I link a couple threads, plan to do a new write-up, but life ya know?

The threads in there are these:

And in this thread, we share them: (Plenty of examples.)

https://www.epiusers.help/t/lets-share-useful-functions-sharing-is-caring/100371

1 Like

You’re doing great Rodrigo.

The services are wrappers around the Business Objects - which are what you see in the Custom REST options. It’s actually more direct access! :wink:

Thanks, I’m digging into @klincecum 's links and will probably end up rewriting the whole thing so that it calls Epicor Functions instead.

It will take some work. And I was almost done.

In the meantime, if someone can be so kind to test this one on their system, I’m not saying it’s the way to go, but it definitely feels like a bug to me:

https://myServer/api/v2/odata/myCompany/Erp.Bo.QuoteSvc/QuoteDtls?$select=QuoteNum&$orderby=QuoteNum desc

I need some closure by knowing it’s not something specific to our system I guess haha.

Unfortunately, we don’t use quotes (because my company is dumb…), and there is no data for me to pull.

That’s fine, it should return an empty list not the “Contact system administrator” error.

Haha, that’s the exact same reason I’m building this app, I figure if I make the quotes happen straight from our CAD system with a streamlined/standardized process, people will be way more inclined to use it.

I’m trying to build an Epicor Function, turns out I can’t because permissions, I’m going to have to go to our system admin again and have him add me to the Access Groups

Functions Administrator
Functions Developer
Functions Power Developer

Can you think of any other basic security clearance thing I will definitely need? This is another reason that I liked the oData calls, I’m not the admin of this system and I hate constantly asking for little tweaks everywhere.

That should probably be all you need unless you do something funky.