Strange issue with the REST helper

Hi, @josecgomez, @jgiese.wci

I was hoping you could help me with a strange issue I can’t find the cause.
I made an application to create a quote from our current quotation system into Epicor, everything works fine in our TEST environment and we finally are getting into production.

However, the application fails the REST calls in that environment. Even more strange, that happens only in some computers, others work correctly. We have machines both working correctly and incorrectly from several windows versions(even Windows 7),

The machines that don’t work in LIVE, still function correctly into TEST, eventhough it is the same code and they just select the environment from a combo. The machines working correctly function with both options without problem.

The error is on the first EpicorRESTAPI reference. For example in just declaring EpicorRestStatusCode for further use, (No instance of an object).

As I said, the strangest thing is that the same application fails with LIVE while it works without problem in TEST in those machines, while in others works fine in both environments. So it all points to some ronin dll or configuration.

Do you have any idea about what the issue might be? Or any ideas in how to debug in those machines more efficently?

I forgot to mention, I am using still api v1, and with the helper 1.1.11

Thanks in advance

What does your code look like? What exception are you getting?
What BO call?

Could it be a cert issue? Maybe the cert used in the Live system has been installed on the working machines and not the others?

You can also look at the event viewer on the machines and the servers.

I get “reference not set to an instance of an object” exception. The error happens at any BO call, but in this example it is to a GET request on UD01Svc. Just filtering rows and retrieving them.


    public void GetProjectData(string company, string projectId, out int custNum, out string custId, out string projectName, out int heightOverSea)
        Dictionary<string, string> dicParam = new Dictionary<string, string>();
        dicParam.Add("$filter", $"Key1 eq '{projectId}' and Company eq '{company}'");
        dicParam.Add("$select", $"Company, Key1, Character01, Character02, Number02, Number03");

        dynamic response;
        EpicorRestStatusCode status = new EpicorRestStatusCode();

        response = EpicorRest.DynamicGet("Ice.BO.UD01Svc", "UD01s", dicParam, null, null);

        if (EpicorRest.LastCallResult != System.Net.HttpStatusCode.OK)
            throw new Exception("No se pudieron obtener los datos de la obra");
            if (response.value.Count == 0)
                throw new Exception($"No se pudo encontrar esa obra con id: {projectId} en la compañía {company}");
                custNum = System.Convert.ToInt32((decimal)response.value[0].Number02);
                custId = response.value[0].Character02;
                projectName = response.value[0].Character01;
                heightOverSea = System.Convert.ToInt32((decimal)response.value[0].Number03);


I guessed as much, but the machine can log to the REST API through the web browser without issues, and nothing appears in the logs(apparently). I’ll take a deeper dig in them.

In this version of the Helper there is a Property called… RequestLog that you should be able to look at after the request and it contains the Request and Resposne Objects in JSON format…

That would help a lot, can you paste that here?

1 Like

I might be doing it wrong, but I set a try-Catch in that code snippet in order to send the appropiate data to the exception message.
However, as I mentioned, this happens at the first call even.
This one:

  EpicorRestStatusCode status = new EpicorRestStatusCode();

So, the exception comes with the RequestLog empty.

However, if I just set it to RequestLog.ToString() I get a different kind of error message,


but I suppose it must be some issue with .ToString() on the empty RequestLog.

Wait you get an Exception inside of EpicorRestStatusCode() … that doesn’t even do anything it instantiates a class.

What do you get in your try catch? What’s the full exception and stack trace?

public class EpicorRestStatusCode
        private HttpStatusCode restCallStatusCode = HttpStatusCode.OK;

        public HttpStatusCode RestCallStatusCode { get => restCallStatusCode; set => restCallStatusCode = value; }

        public EpicorRestStatusCode(HttpStatusCode httpStatusCode)

            this.restCallStatusCode = httpStatusCode;

        public EpicorRestStatusCode()
            this.restCallStatusCode = HttpStatusCode.OK;

I know, I made a simple application with just that request so I can test it faster.
This is the exception message and stack trace. Sorry about the spanish, but it is Reference to an objetn not set to an instance of an object(I believe it is the correct translation).
The stack trace now shows what should be the correct line

I mean, an actual request. But still, the RequestLog seems to be empty. I added a EpicorRest.RequestLog.ToString() to the end concatenation and nothing is shown.


It looks like its receiving a response from the box that is not in JSON format that’s why its exploding…

can you install fiddler? and take a look at the response from the server?

Hi @josecgomez
I’ll read the documentation, I must say I’ve never used fiddler nor I am expert in http requests/responses but I will take a look on it to see how it works.I’ll get back to you later.

On one of these computers that doesn’t work can you hit that BAQ from Postman? or from the Web? Do you get any weird certificate warnings?

What is your “Setup” section of code like? (where you set the host app instance etc)

Is it the same user on all the machines?

Also I had some weird issues when the BAQ wasn’t shared or I had the wrong server address. It didn’t report the error back.

You can also set visual studio to break on all exceptions in case there is an inner exception being missed?


The new version has have much better error handling and returns the entire response object

It is compatible with v1 and v2 of Epicor rest

Yes, I can hit the request through the web browser with no issues in that machine. No error shown.
The setup is quite plain:


        EpicorRest.AppPoolHost = "SERVER";
        EpicorRest.AppPoolInstance = "LIVE";            
        EpicorRest.IgnoreCertErrors = true;
        EpicorRest.UserName = "QuoteUser";
        EpicorRest.Password = "QuotePassword";


The data is not sensitive

And you are sure the server name and instance aren’t misspelled? there is no extra slash in the server name or instance?

AT this point you need to observe the call to figure out the error (with fiddler) or upgrade to the latest version of the library which has more robust error handling.

Fiddler is not hard to use you just install it open it enable SSL decryption and run your application. You should see that call the API makes and see the response from the server.

Hi @bmanners

Yes, it is the same user in all machines. It is a special user so we can ensure which quotes were entered that way(I could use a UD field for that, but also that way I am controlling the company being used).

Since that machine doesn’t have Visual Studio, I can’t test it that way. However, I might end up installing it in case it can bring more input about this issue. It is quite strange, since same code works in other machines. Even worse, same code works in those machines in another environment. So it should be something related to the AppServer and that client machine, but can’t find the reason.

I can call the request without issue from the web browser which is weirder since I would expect the issue arise there also.


Thanks, Fiddler should be installed in the server right? I’ll try it out

No in the workstation.