REST API clarifications needed

Hi,

I’m a Windows desktop application developer. I’ve been asked to look into the Epicor 10 REST API for integration with existing custom in-house applications.

I’ll be mostly working with the Erp.BO.PartSvc and Erp.BO.EngWorkBenchSvc services.

While testing things out with the Swagger tool, I noticed that the PartSvc.PartRevs “endpoint” (May not be the right naming, I’m still pretty green to all this) was not returning any data.

The Request URL:

_https://svrepicordev/ERP10Dev/api/v1/Erp.BO.PartSvc/PartRevs_

The Response body:

{
_ “odata.metadata”: “https://svrepicordev/ERP10Dev/api/v1/Erp.BO.PartSvc/$metadata#Epicor.RestApi.PartRevs”,_
_ “value”: []_
}

Also, no matter what I set as the $filter expression, the Response body’s value is always empty.

On the other hand, if I use other endpoints based on GetByID, and pass in the same parameters, then I get the expected values returned.

I get the same behavior with other endpoints such as PartSvc.PartRevAttches.

So my question is whether the PartSvc.PartRevs endpoint should actually return something, or not. My feeling is that there is something wrong with the customer’s setup.

Any insight greatly appreciated.

Cheers

There is a very long post in the experts corner about REST check it out. Rest Overview Novel

Yes, I have read it, but it does not directly address my concern.

Thanks for the reply though :slight_smile:

1 Like

Some of those sub tables behave quite funny. Have you tried using the PartRevSearch one instead see if you have better luck?
URL: api/v1/Erp.BO.PartRevSearchSvc/

Ah!

Funny enough, that one returns data:

_https://svrepicordev/ERP10Dev/api/v1/Erp.BO.PartRevSearchSvc/PartRevSearches_

Too bad there isn’t one directly on the PartRevAttches :confused:

I was discussing this with another “consultant”, and they’re telling me that the Swagger tool exposes methods/endpoints that are not really “supposed” to be there.

I brought up this question: How would you issue a query that would return all the PartRevAttches whose FileName ends in “.PDF”… They say I should get the Parts, then the PartRevs and then the PartRevAttches. I said “so much for efficiency” :rofl:

Cheers

You can use the GetBYID or GetRows BO methods instead (Still through rest) look at the Custom Mthods.

Well, I thought the PartSvc.PartRevAttches used “GetRows” under the hood.

Forgive my greenness, but how would I call getRows directly on the PartRevAttches?

Thanks a lot by the way!!

You don’t, the PartRevAttch table is in the returned dataset from GetRows

Yes, I’m trying to decipher the POST at the moment…

I’m sending a json object and I set the “whereClausePartRevAttch” : “PartNum eq ‘XXXXXX’”

I’m getting back a 400 code, with the message saying “Parameter PartNumber is not found in the input object”.

I do not understand, as the field is really “PartNum”.

Can you shed some light on my poor tired brain :wink:

Cheers

Forget it, I’m an idiot, I was calling the wrong method (I’m using PostMan).

The request is taking quite some time to process though.

I’ll see if it times out.

Cheers

1 Like

An alternate strategy is to write a BAQ and use the BaqSvc. You can pass in the parameters and do all the linking and selection on the server. Bonus: less likely to break on upgrades and you would only have to fix the BAQ if it did break and not have to fix all of your programs.

4 Likes

As I thought it would, the server timed out and returned a 500.

I’ve been getting a lot of 500 when using the OData methods of the PartSvc, as described in my OP.

For example, this is a sure 500:

https://svrepicordev/ERP10Dev/api/v1/Erp.BO.PartSvc/PartRevAttches?$filter=Company%20eq%20’XXXXX’%20and%20PartNum%20eq%20’YYYYYYYYY’

(I’ve replaced the sensitive data with X’s and Y’s)

My feeling is that the server is borked.

Any thoughts on that last 500?

Mark,

I’m not allowed to use BAQs unfortunately.

As is often the case, “too many chefs ruin the sauce”. I have to abide by what the principal consultant in this project says. I’m sure I could convince the end user, but I choose my battles carefully :wink:

Thanks

I guess if the principal is trying to book hours, using BAQs would not be the way to go - especially if they’re trying to guarantee some follow up revenue for upgrades, etc… :rofl:

And speaking of one chef ruining the sauce, I just listened to an entertaining Ted Talk about Micromanagement. You all might find it entertaining too.

Mark W.

3 Likes

Try this by filling in the parameters in parenthesis

https://server/instance/api/v1/Erp.BO.PartSvc/PartRevs(company,partnum,rev,altmethod)/PartRevAttches
1 Like

Hi Theo,

Thanks for the sample, but I was merely giving an example of our server erroring out.

What I’d like is for someone to confirm that the /PartRevs and /PartRevAttches methods, without any $filter, are working, or not, on their setup.

If you have a few minutes, I’d appreciate knowing your results.

Thanks

I just tested /PartRevs and /PartRevAttches without a filter.

  • /PartRevs returns some data when run without filters but certainly not all part revisions.
  • /PartRevAttches never returns anything for me.

You may have better luck using the Ice.BO.AttachmentSvc and using $filter RelatedToFile eq ‘PartRev’

https://server/instance/api/v1/Ice.BO.AttachmentSvc/Attachments?$filter=RelatedToFile%20eq%20'PartRev'

This will return the part number in Key1, revision in Key2, filepath in XFileRefXFileName, and file description in XFileRefXFileDesc. Unfortunately you can’t filter on something like *.pdf in the API call itself because the XFileRefXFileName field is not native to the attachment table (it’s extended from XFileRef). Depending on how many attachments exist for part revs, filtering the response application-side shouldn’t kill performance too badly if you trim down the data return to just what’s necessary.

2 Likes

Jacob,

Thanks, this is starting to put my concerns to “rest”. I see that there are actually a lot of Svc that I should look into when the “intuitive” one won’t do.

Good thing you explained about XFileRef, as I was already planning on going down that path :wink:

Best regards

One tidbit on the 500s - that just means we don’t know if the stack trace and exception have sensitive data so are hiding it by default. You can look in the Windows and App Server logs for details: PLEASE look in the 'Flight Data Recorder' - ERP 10 - Epicor User Help Forum

If this is a dev/test box, you can expose these exceptions via a web.config setting
<configuration>
<system.web>
<customErrors mode=“Off”/>

Not a good idea in the wild because you never know when the CEOs salary or whatever appears in an exception. For test, it is safe.

2 Likes

Hi Bart,

yeah, the CEO would be very happy :slight_smile:

I’ll try to get this modified. It shouldn’t be a problem as it is a Dev environment.

I’m having other “issues” with the main contractor at the moment. You know, when they tell you “no worries, when you need help, just give us a call”…

Cheers