This is a generic C#/.Net error that simply states:
“Hey, you’re accessing a variable that hasn’t been assigned anything and you’re not testing for that condition. You better fix it”
More often than not, a record is not found the the code assumes that can’t happen but it can be other reasons too. Go through your code and do some null checking to put guard rails around unexpected missing data.
I tried using the var results != null but this behavior causes the same error before the code runs. The current Null error happens after the 1:40 minute mark of the program. That is why I believe that it is a time out thing. How do I tell the code not to time out?
Are you seeing a timeout error in your logs? Are you using Try/Catch blocks around your code and handling error handling explicitly?
If you’re timing out, then you need to fix the query you’re running. Make sure you’re using keys properly in links. Do your most restrictive query first to a list then use the list to add extra data as needed.
I just realized I was trying to pass credentials in the Params section instead of the authorization section…happy second Monday?
I can get PostMan to Pull that query pretty fast without any issues, which means that the dynamic get section of code seems to be the problem. Are there better ways of getting the data compared to the following:
Was the nuget package updated? (Maybe a bug in DynamicGet)
Was epicor updated just before the error started? (A bug in Epicor, if possible enable server logging and see if the errors appear there)
Can you try a system baq or a new but simpler baq instead of APOTool2? (Maybe something specific to this BAQ causes the error?
I updated the nuget package earlier, should be up to date. We haven’t had an upgrade recently, at least not since this last worked. As for trying another baq it exits with code 0… not sure what that means. Thanks for the insight!
As far as performance goes, I’ll leave that to @josecgomez and @jgiese.wci as they are the authors behind that library and know how to make it sing.
Quick note about Basic Authentication. As you see, the username and password is encoded but not one way. This is why Epicor requires us to have certs protecting the traffic. Any persistent threat on your network will be looking for Basic Auth headers going by to pick out credentials and grab any API-Keys. Eventually, you’ll want to get to token access. It’s documented in the REST guide but I’m pretty sure the NuGet package does it too.
This is the first I’m hearing of a token option. I will have to dig into that. Do you have the Rest guide notes handy?
I am currently using v1.1.11 of the EpicorRestAPI. I see a RESTLOG option in the code. What would be the optimum placement for a Restlog statement to go, before the line causing the error, on the line causing the error, or after? Also, what would the RestLog statement look like?