Integration Doc - Beta testers needed

Search msdn. Export key, import to trusted publishers or something. I’ll find the article when the grandsons are not torturing me…

i have done that @Bart_Elia … imported the certificate and added to my trusted certificate list … still didnt resolve the issue. i will also try to work out something in c#. take it easy and enjoy grandparenthood …

Which example were you running to get that error and which binding are you running?

Anything binding can be used for the Impl as long as the client and server match.
The SOAP REQUIRES BasicHttp or SOAPHttp at the server.
REST does not use bindings so doesn’t care.

Which are you having issues with?

Note #1 - Ensure setup instructions are pointed out. I assumed since the same setup is used as we have had for years I could omit setup.

Lessons learned. Will update when off pop pop duty :wink:

1 Like

I’m trying REST … it debugs through prepare headers method, exception raised at query method at the line sendAsync.Result,

I’ve just done the setup for this on my test system. I was able to login once to https://EpicorTEST01/ERP101600ChillStore/api/help, and from another PC as well (had to create the firewall rule for port 443). Now though, whether on the server or the same PC that was able to connect remotely, I just get an HTTP 500 error. I’ve rebooted the server, but still the same.

Any clues? Nothing changed between it working and now not.

Many Thanks
Mark

Hope you have installed the certificates in client pc, and Restart IIS, add the site to trusted zone in ur client machine … run browser as admin …

500 error is what everything is mapped to all the time - this was discussed at Insights how everything is mapped to it for a result code and details are logged in Server Event log - known limitation for now. See the article ‘Flight Data Recorder’ up here for details

I got it working again by playing with the authentication methods available on the virtual folder in IIS.

Anonymous Authentication was already enabled
I enabled Digest and Windows auth, and now it shows me the help, and I can try using the examples given by Bart but I now get a failure because the password is expired.

We don’t use Epicor usernames and passwords usually, it’s configured to use Windows auth and SSO. I have tried on my test system allowing net.tcp and HTTPS with the option HttpsBinaryUsernameChannel. What does my client config file need to look like, to be able to connect to the app server using https to reset password? When I try connecting now, I immediately get an error:

[/uploads/default/original/2X/e/e384d590be666d06047152591b22f87095fc1c6a.png]

My config file key lines are these:

Many Thanks
Mark

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.

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

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

1 Like

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.

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

i don’t see sysconfig in this post.

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

2 Likes

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

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:

2 Likes

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

6 Likes
2 Likes