I set up the CallService and StreamWriter as suggested but I still get the same error.
How do I verify the client’s auth vs the server’s auth? I would have thought that setting the APIKey up would have created the proper environment for making a call like this.
This is getting more complicated than it is worth. The person who would be executing the function is smart enough and has the permissions to kick it off with the Schedule Epicor Function. I am going to abandon the button click process. Thanks for all of the advice!
I decided to make another attempt at calling a function from a button click.
I am calling a different function than before. This one does not take any parameters. I have this code in my button click event:
const string apiKey = "U3FoF6HadakgFQ9LrwFN*****";
try {
var restClient = new RestClientBuilder()
.SetDefaultApiKey(apiKey)
.UseSession(oTrans.CoreSession)
.Build();
var functionContent = new RestContent(new{});
var functionResponse = restClient.Function.Post("MyLibrary", "GetWBSDates", functionContent, published: true);
}
catch (System.IO.IOException e)
{
// If just catching and then immediately rethrowing then consider not catching the
// exception here to avoid making it look like exceptions are happening in multiple areas.
// Maybe catch where you are calling CallPostFunction instead. Doing it this way will just
// generate a new exception with an identical exception in the InnerException property.
// Just a suggestion.
throw new System.IO.IOException("IO REST Call", e);
}
catch (Exception e)
{
// Keeping this catch will cover any other unhandled exceptions that might come up
throw new Exception("REST Call", e);
}
My library is published. I have only one company so I know my permissions are fine. I keep getting this generic REST error and I have no idea how to determine what is wrong.