REST Erp.BO.LaborSvc

I have undertaken converting our numerous internal web based asp.net ‘applications’ to use the Epicor REST API instead of the older WCF services. Most of them just called BAQs and those converted easily using the NUGET REST helper. I am now tackling the Start and End Activity app. The WCF based app follows the method calls found in doing a trace of the client and works well. I have started to duplicate the functionality using REST calls. I have gotten as far as calling the StartActivity method and it returns a new LaborDtl record. When I call the DefaultJob method I get the http 400 error “Labor has not changed”. I have searched the forum topics and found a post with same error message on the same method. The suggested resolution was to set the RowMod on the LaborHed data, but there is no LaborHed data returned from the StartActivity call so I am stumped.

I tried to enable the api logging on the server and no useful info was returned.
Is anyone using the REST API to start and end labor activities that could share how they did it?

Thanks,
Bernie

Hi @bw2868bond what does your code look like? I’m guessing you need to send in a RowMod.

1 Like
var postData = new {
                        LaborHedSeq = int.Parse(this.ViewState["LaborHedSeq"].ToString()).ToString(),
                        StartType = "P" ,
                        ds = responseHed
                        };

            dynamic responseDtl = EpicorRest.BoPost("Erp.BO.LaborSvc", "StartActivity", postData);

            dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(responseDtl.ResponseBody);
            jsonObj["parameters"]["ds"]["LaborDtl"][0]["JobNum"] = this.txtJobNum.Text;
            jsonObj["parameters"]["ds"]["LaborDtl"][0]["RowMod"] = "U";

            var postJob = new
            {
                jobNum = this.txtJobNum.Text,
                ds = jsonObj
            };
            dynamic responseJob = EpicorRest.BoPost("Erp.BO.LaborSvc", "DefaultJobNum", postJob);```

Send two records, the original one with RowMod empty and the updated one with RowMod U and see what happens.

I have it working now. In case anyone finds this post years from now, There were too many extras being sent as the data set. Working code:

var postJob = new
            {
                jobNum = this.txtJobNum.Text,
                ds = responseDtl.ResponseData.parameters.ds
            };
            dynamic responseJob = EpicorRest.BoPost("Erp.BO.LaborSvc", "DefaultJobNum", postJob);
4 Likes

jsonObj[“parameters”][“ds”][“LaborDtl”][0][“JobNum”]

This syntax is pretty clunky. These can be accessed just as they are:

jsonReturn.parameters.ds

and, being a JSON type in .NET, you have fun things like First and Last as variables.

jsonReturn.parameters.ds.LaborDtl.Last

I also pass the dataset around from each call, but as you now are aware, the return object isn’t exactly the same as your input, so it needs to be altered before being provided.

If you need any further help, I actually just wrote this all out yesterday for our MES app.

1 Like

I managed to remove the quoted code once I figured out how to get past the ‘parameters’ and ‘returnObj’ bits in the responses and use the actual data. :slightly_smiling_face:

Thanks for the offer, but I am pretty sure I have it working now