REST Overview Novel


(Lee Fry) #81

Hey Guys,

Is there any advanced documentation floating about for the Rest API (more specifically for the custom methods variant)

I’ve been able to do all sort of fun magic with this API in golang so far- however the one thing I’ve not been successful at is adding materials or operations to a part via the EngWorkBenchSvc so was hoping there may be so shiny documentation other than whats available on the swagger pages.

Also @Bart_Elia Do you know if there will be a recording or some slides available for those unable to attend you Insights lab?

Thanks in advance


(Jose C Gomez) #82

@Lee_Fry GoLang!!! you get extra points!!!


(Bart Elia) #83

I am not sure the availability of Insights material outside of Insights. I’ll dig into those details internally. You can always ping me here or on twitter as many of you already like to pester me :wink:
<Warning random tweets may occur on the Trailblazers or Minecraft - I have grandsons, don’t judge :wink: >

I have a few things on my wish list but not on the roadmap for REST in 10.2 so no commitments yet.
A couple of things I want to do:

  • Improve company handling
  • Add additional metadata (No extended property details in swagger yet)

Another general wish is increased ‘business documentation’ around certain popular areas. I think we have all seen enough docs from many APIs and many companies that define Name: The name of the thing.
What I would like to see is more business process oriented descriptions from the API help along the lines of MSDN style remarks.

Stay tuned…


(Lee Fry) #84

@josecgomez Thanks ^.^ I do love the golang! hehe!

@Bart_Elia Thanks for the heads up, I shall keep tuned in- and a little excitable! :slight_smile:


(Theodore Koch) #85

Hi Lee,

I put this together because I was also curious how the custom methods worked. See below, not if this is the best way, but the first way I figured out how to make it work.

        static void Main(string[] args)
        {
            var client = new RestClient(_serviceUrl + @"/Erp.BO.SalesOrderSvc/GetByID");
            var request = new RestRequest(Method.POST);
            request.AddHeader("authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "shop", "shop"))));
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", "{orderNum:7045}", ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            SalesOrderTableset ds = new SalesOrderTableset();

            JObject jo = JObject.Parse(response.Content);
            ds = jo.SelectToken("returnObj", false).ToObject<SalesOrderTableset>();            

            ds.OrderHed[0].PONum = "TEST";
            ds.OrderHed[0].RowMod = "U";

            string data = "{\"ds\":" + JsonConvert.SerializeObject(ds) + "}";

            client = new RestClient(_serviceUrl + @"/Erp.BO.SalesOrderSvc/Update");
            request = new RestRequest(Method.POST);
            request.AddHeader("authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "shop", "shop"))));
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", data, ParameterType.RequestBody);
            response = client.Execute(request);
        }

EDIT Figured out how to add a new line also (FYI). Probably not the most elegant way, but still playing.

        static void Main(string[] args)
        {
            var client = new RestClient(_serviceUrl + @"/Erp.BO.SalesOrderSvc/GetByID");
            var request = new RestRequest(Method.POST);
            request.AddHeader("authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "shop", "shop"))));
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", "{orderNum:7045}", ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            SalesOrderTableset ds = new SalesOrderTableset();

            JObject jo = JObject.Parse(response.Content);
            ds = jo.SelectToken("returnObj", false).ToObject<SalesOrderTableset>();            

            string data = "{\"ds\":" + JsonConvert.SerializeObject(ds) + ",\"orderNum\":7045}";

            // add new line
            client = new RestClient(_serviceUrl + @"/Erp.BO.SalesOrderSvc/GetNewOrderDtl");
            request = new RestRequest(Method.POST);
            request.AddHeader("authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "shop", "shop"))));
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", data, ParameterType.RequestBody);
            response = client.Execute(request);

            jo = JObject.Parse(response.Content);
            ds = jo.SelectToken("parameters", false).SelectToken("ds").ToObject<SalesOrderTableset>();

            Epicor.SalesOrderSvc2.OrderDtlRow row = ds.OrderDtl.FirstOrDefault(r => r.RowMod.ToUpper() == "A");
            row.PartNum = "test";
            row.LineDesc = "test";

            // update
            data = "{\"ds\":" + JsonConvert.SerializeObject(ds) + "}";
            client = new RestClient(_serviceUrl + @"/Erp.BO.SalesOrderSvc/Update");
            request = new RestRequest(Method.POST);
            request.AddHeader("authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", "shop", "shop"))));
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", data, ParameterType.RequestBody);
            response = client.Execute(request);

        }

(Lee Fry) #86

Hey,

Thanks for this, it’s nice and simple to follow, I shall convert it to golang and see how I get on with the EngWorkBenchSvc as this is where I’m having some problems with currently.

With all the other stuff I did such as CRM notes, customers, and part creations I could get away with just calling the UpdateExt method, and that would take care of adding a new or updating a record for me, whilst With the EngWorkBenchSvc it seems to require little more depth, such as GetRows, GetNewECOMtl, ChangeECOMtlMtlPartNum & then Update.

Thanks again.
Lee


(Brandon Anderson) #87

Nice work on the rest presentation @Bart_Elia. I’m not a programmer and it’s nice to see what you can do easily with this.


(Greg Heeley) #88

Hi Bart
After attending the Extended Ed session on REST, I went looking for Brian’s GitHub repository and there’s nothing there for the example Web Page, I’m being a bit lazy but it would be great to get hold of the finished example.Any clue on where It could be obtained?
Cheers


(Jose C Gomez) #89

Greg
There are several examples in Brian’s git hub, are you sure you weren’t too the right place?


(Leon Feder) #90

Hi Bart,
I loved your presentation at Insights and have gotten somewhat set up to start playing around with the API. A few parameters are important to state up front. First, we’re a single-tenant cloud customer. Second, I’m very new to Epicor and haven’t had to deal with web server configuration for the past two decades (I did a lot of early work with Apache before the wheel was invented).

If I do a remote desktop to the hosted server, I am able to access the API. However, when I try to access it outside, I receive the following error (actual URL changed in Chrome):

This site can’t be reached
99999-e10-test.epicorhosting.net’s server DNS address could not be found.

I was asked by EMS:
Have you imported the self-signed certificate to the Trusted Root CA as per the guide?
You can import the self-signed certificate by double-clicking on the PRX file and it will launch a wizard to take you through the process (it’s in the guide as well).

I’m not sure where to find this information or what I’m supposed to do. I assumed that I would be asked to import a certificate in the browser when I tried to access the URL but I didn’t get that far. Should I be able to access the API outside? I would hope so. Is it an IIS configuration issue?


(Olga Klimova) #91

looks like your browser does not see 99999-e10-test.epicorhosting.net
Certificates are not involved here yet.


(Leon Feder) #92

I agree. As a cloud client, I’m wondering if there’s a separate “Public” URL I need to use. The 99999-e10-test.epicorhosting.net address does not seem like what users would enter. I’m just wondering what step is missing. Is this something defined in IIS?


(Bart Elia) #93

Leon, reach out to your SaaS admins. They should know how to flip the switch. It sounds like whatever you have for a certificate is not trusted by your client PC. This is a normal thing when a dev stands up a test certificate on a server - then any client trying to contact the server has no clue if it should trust it or not. That’s the whole point of Verisign, LetsEncrypt, etc. They work with Microsoft so the OS trusts those certificate vendors so you don’t have to manually add anything to your certificate store on your client.
Either that or the port is blocked. Start with the SaaS admins, they know me too well :wink:


(Chris Conn) #94

FYI - Bart Ellia and Brian Conner just did a REST webinar over at EUG. If you are an EUG member, you should be able to access it in a few days.

Thanks @Bart_Elia


(Bart Elia) #95

@bconner did the presentation. I was there for comic relief…


(Ed Welsh) #96

The webinar was great, You asked me to reach out about the bug decrementing the PwdGrace value in the Ice.SysUserFile table. Is there a workaround, currently I have put a very high value through tsql?


(Ken) #97

Hi, I’m having trouble filtering by guid. This what I think is supposed to work, but I’m not having any luck:

$filter=SysRowID eq guid’XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX’

I’ve tried a ton of variations like the v4 way ($filter=SysRowID eq XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) and nothing seems to work, I just keep getting 500 error back. I’m able to filter on other fields so I know I’m not completely terrible at this, I’m just stumbling on the row ID. Is it possible to filter on SysRowID?

Thanks for any help.


(Olga Klimova) #98

What version do you use? it was fixed at some point
Syntax should look like $filter=SysRowID eq guid’e830ab94-680b-49fe-882c-9f9d0117ac39’


(Ken) #99

We’re on Epicor 10.1.500.18. We have someone else administering Epicor so I’m not 100% knowledgeable on what versions fixed what, but I’ve heard talk that this one is pretty early in the REST evolution, so it would make sense that we’re just using an old version that has some bugs.
I’ll get with the team and push them to update to the latest and see how it goes, thanks! and thanks for letting me know what it should look like too.


(Olga Klimova) #100

yes, it will be in 500.20+