Integration Doc - Beta testers needed


(Bart Elia) #21

Mark - which approach are you struggling with? Since I described three I only have a 33% chance of guessing correctly :wink:

BTW - not sure what’s up but I don’t see the png.


(Mark Damen) #22

It’s more of a tech query on the app server. I only ever use windows auth, so have no experience with Epicor username/password method. Can’t seem to connect Smart Client to App server, to be able to reset the password. For rest, I created a new user – but can’t set the password using windows auth .sysconfig obviously. The error says:

            Secure channel cannot be opened because security negotiation with the remote endpoint has failed.

When you deploy an app server in Admin console, it creates a shortcut on the desktop. But it only creates the shortcut for net.tcp, because it sees that first. Think that’s what I’ve understood to be intended behaviour. I have net.tcp and https defined on the same app server, and just struggling to get the https connection working. Can I alter that app server to be just net.tcp, and then create another one using https separate? (in the hope that it will then set the correct auth methods, and create me the .sysconfig file).

Regards
Mark


(Olga Klimova) #23

If you install self-signed certificate, then export it and import on client machine’s Trusted People store and it still does not work - then the most probable cause - you use incorrect host name in your address,

Usually, in the simplest case, self-signed certificate is generated for the machine FQDN - like server.domain.com. This name is written in th Subject name of the certificate. And when you are connecting from client - you need to use exactly the same name.
So if the Subject Name contains
CN=server.domain.name,
then your address should be
https://server.domain.name/Epicor/api/help
and not
https://server/Epicor/api/help
or
https://localhost/Epicor/api/help
or
https://my-ip-address/Epicor/api/help


(Olga Klimova) #24

you need to use another admin user. Connect using rich client and reset password for the new user in the USer Account Maintenance. Also there is no special code to set new password for the new user throught REST. User should be set up before.


(Mark Damen) #25

Yep, I realise I need to reset password through rich client. My current issue is that the rich client won’t connect, even on the server. I posted the relevant lines from my sysconfig file, do they look correct for https connection?

Many Thanks
Mark


(Olga Klimova) #26

i don’t see sysconfig in this post.


(Mark Damen) #27

Hi

Taking a break and looking at it with fresh eyes was all that was needed. I had it configured to HttpsBinaryUsername in the admin console, but HttpsBinaryWindows on the client sysconfig.

All working!

Thanks all for help,

Regards
Mark


(Mark Damen) #28

Bart

Your REST example is now functioning, in that it connects without error and shows the elapsed time. I said before I was right at the beginning on this, and teaching myself C#… to get say the Customer.Name or Customer.CustID to output to the console, it is a case of parsing the jsonResponse and looking for that key, or does the jsonResponse need to be mapped to a custom class (eg Customer)?

Thanks
Mark


(Bart Elia) #29

After being on the road for 3 of the past 4 weeks I am out of office and only poking my nose in from time to time. If my list of honey do’s gets caught up I may find a PC to respond or I’ll grab it when back to work next week :slight_smile:


REST Overview Novel
(Jose C Gomez) #30

Let us remember that @Bart_Elia is doing this on his free time and he is a super busy guy, so let’s give him some room to breathe!
With that said, attached is a class I generated from the customer meta data

CustomerCls.cs (66.6 KB)

Basically it is an object representation of the JSONObject returned by the REST API. With this class in your project you can now serizlize the JSON into it and use it like you would the CustomerDataSet in the WCF Example.
Simply replace the QueryCustomer() method with the one below once you’ve imported the class into your project.

private static void QueryCustomer()
        {
            //Stand up which service to call
            HttpRequestMessage request = new HttpRequestMessage(
                HttpMethod.Post,
                ServiceUrl + "/Erp.Bo.CustomerSvc/GetByID");

            //Add the json payload
            request.Content =
                new StringContent(
                    JsonConvert.SerializeObject(
                        new
                        {
                            custNum = 2
                        }),
                    Encoding.Default,
                    "application/json");

            try
            {
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                //Make the call
                var response = httpClient.SendAsync(request).Result;

                stopwatch.Stop();
                //var jsonResponse = GetObject(response);

                //Deserialize JSON Response into our JSONCustomer object
                JSONCustomer custDS= Newtonsoft.Json.JsonConvert.DeserializeObject<JSONCustomer>(response.Content.ReadAsStringAsync().Result);
                //Display the Customer's Name
                Console.WriteLine(custDS.returnObj.Customer[0].Name);

                //Console.WriteLine("Success:{0}", response.StatusCode == HttpStatusCode.Created);
                //Console.WriteLine("Response:{0}", jsonResponse.ToString());
                Console.WriteLine("Duration:{0}", stopwatch.Elapsed.TotalMilliseconds);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }

You can generate the class a couple of ways, there are libraries out there that understand OData and will allow you to generate classes from the meta data directly, there are web utilities that will do it too (https://jsonutils.com/). The easiet way to do it is to paste the mata data into a visual studio class using the Paste Special functionality


Releasing a license from an external application
(Ed Welsh) #31