Bit of a cheeky ask here but can anyone help us with a solution that has already been developed to issue materials using a visual studio App that uses REST . Any help would be appreciated
Not if this is all the information we are given
Not sure what you would need, we had a working vs app using WCF/dll links to process material issues. We can no longer use this as WCF does not work with 2023.2 version of Kinetic (we are upgrading from 10.2.400).
It seems that using REST is the way to go but we have no experience of this, we have some code working in Postman which is hard coded to issue materials for one job that does work but can not get this working in vs c#.
Basically, we have a number of files in a folder that contain jobnum, asmseq,mtlseq and tranqty - picking these files up we need to process them using BO.IssueReturn to update Kinetic.
Any help would be appreciated, even a simple visual studio solution that uses Epicor Rest API to process something similar would help (we can handle picking up the files and reading them as we can use the current coding we have for this)
Are you using the Epicor Rest API given here?
Its really not any harder than WCF I donât think. He has some examples in that post. Try making a test call to IssueReturn with that API and post what you come up with, and people can help you.
Or, you can zoom out and tell us what this program is doing for the company and why its needed, and it might be possible to address the issue directly in Epicor or by changing a process.
Thanks Evan.
This is the code I have so far: -
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using EpicorRestAPI;
using RestSharp;
namespace WindowsFormsApp2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
EpicorRest.AppPoolHost = "*******";
EpicorRest.AppPoolInstance = "KineticTest";
EpicorRest.UserName = "******";
EpicorRest.Password = "******";
EpicorRest.APIKey = "************************************";
EpicorRest.Company = "COMP01";
EpicorRest.APIVersion = EpicorRestVersion.V1;
EpicorRest.License = EpicorLicenseType.Default;
EpicorRest.IgnoreCertErrors = true;
CallContextHeader callContext = new CallContextHeader();
var postData = new
{
Company = EpicorRest.Company,
TranQty = 30,
ToJobNum = "1177333",
ToAssemblySeq = 0,
ToJobSeq = 30,
};
var response = EpicorRest.BoPost("Erp.BO.IssueReturnSvc", "GetNewIssueReturn", postData, callContext);
}
}
}
When I run the debug I am getting the below
What version of .NET is your Project?
Make sure you install the RestSharp pre-reqs
REstSharp 108.0.3 and Newtonsoft 13.02
yes sharp is in the wrong version
Thanks, I have changed it now to 108.0.3, when I ran the Debug it still errored as was referencing 110 version still.
I manually changed the ânew versionâ show below
The program has now run and is not showing any errors but the material posting still didnât happen, any ideas?
What response do you get? Your response
object should have some properties indicating if the server said it was successful or returned an error.
Sorry Evan, where do I see that? There is nothing popping up with any messages.
I have also just noticed this in warnings:
As you can tell, I am a novice at this and I am appreciating all help
uhh I have no idea how the professionals go about it, but a quick and dirty way would be to add a line of code after the rest call and put a break point on it, then you can look at all the properties of the response
object in the watch window.
Thanks, I will try that - I have removed the first warning now too, I had forgotten to rebuild the project after changing the RestSharp version.
I am just left with the âpackagesâ element is not declared now
Try doing this after the response code
string jsonResponse = JsonConvert.SerializeObject(response, Formatting.Indented);
Console.WriteLine(jsonResponse);
But as @t.mattick said a debugger may be a better choice
I know nothing of VS, but Iâll say what has not been said yet, which is: have you thought about using an Epicor Function?
Get the EFx working (you can test it with Postman) and then call it in your app.
Iâve dealt with the IssueReturn
BO and it has many quirks. Not sure if you have experience with it already or not.
I concur.
Agreed, if they gather up the entire list of jobnum, asmseq, mtlseq and tranqty and send it as json to an Epicor Function on the server it will reduce the number of rest API calls being sent over the wire, making it a better solution. That said, they will still need to learn how to make a REST api call (to the Epicor Function) and deal with the IssueReturn
quirks (now inside the Epicor function)
My personal view is to continue to use what you are using and get it working with the view to learn functions then implement thatâŚlittle bites rather than one big bite. You have something that did work and just needs to be tweaked but moving forward is not suitable for web server tech
Another option for you would be to continue to use WCF and transition to REST Service Calls or Kinetic Functions as time allows. WCF is still supported with Kinetic - you just need to register the Service to enable WCF. Search help for WCF - there is a SQL Script you need to modify / run to enable WCF for the Service you need.
Now, that said, WCF is on the way out. You definitely need to allocate some time and convert to REST Calls or rewrite to use a Function.
Hi all, thanks for your comments, I will be working through them today to see if I can get it working.
I would love to keep what we have already (WCF) and then take the time to learn REST and functions to replace the program but was told it wonât work with 2023.2, will the SQL Script work for this version?