API Labor Entry Call

I’m a heavy DMT user and am transitioning to more API call entries. We have a lot of ‘non-Epicor’ stuff happening on our shop floor hence the reason for the alternate entry methods. I’m a total (almost) newbie to API calls. I’m trying to feed the API like I would DMT and it’s not going. What is wrong with this LaborSvc POST call?

curl -X 'POST' \
  'https://redacted/api/v2/odata/99927/Erp.BO.LaborSvc/LaborDtls' \
  -H 'accept: application/json' \
  -H 'X-API-Key: redacted \
  -H 'Content-Type: application/json' \
  -d '{
  "Company": "99927",
  "EmployeeNum": "100",
  "LaborHedSeq": 9909909,
  "LaborDtlSeq": 9909909,
  "LaborType": "P",
  "LaborTypePseudo": "P",
  "JobNum": "P6B-test",
  "AssemblySeq": 0,
  "OprSeq": 10,
  "LaborHrs": 0,
  "BurdenHrs": 0,
  "LaborQty": 10,
  "Complete": true,
  "LaborRate": 60,
  "BurdenRate": 40,
  "OpComplete": true,
  "CompleteFlag": true,
  "LotNum": "MF1111106162024"
}'

I get this: (Yes my Employee ID is valid when entered inm the UI)

{
  "HttpStatus": 400,
  "ReasonPhrase": "REST API Exception",
  "ErrorMessage": "A valid Employee ID is required",
  "ErrorType": "Ice.Common.BusinessObjectException",
  "ErrorDetails": [
    {
      "Message": "A valid Employee ID is required",
      "Type": "Error",
      "Table": "LaborHed",
      "Program": "Epicor.RESTApi.Common.dll",
      "Method": "ThrowUpdateExtException",
      "ColumnNumber": 17,
      "LineNumber": 27
    }

And humbling me is perfectly ok :smiley: (call me dumb) if you have some help for me

1 Like

I edited your post and redacted your server and API-Key information.
Be careful with that… :wink:

3 Likes

Sorry, I should know better…

2 Likes

Probably want to go here, in the custom methods in swagger / rest help.
/server/api/help/v2/odata/Erp.BO.laborSvc/index.html?urls.primaryName=Custom%20methods#/Custom%20methods/Update

Use that endpoint.

You’ll want to send it a dataset with a LaborDtl in it, formatted properly.

Am I looking at this properly then with onl;y passing fields that need ot be there like I owuld for DMT?

Also can I just delete out the LaborEquips and LaborComments if I don’t want them?

For this, probably.

Something like this is more like what you need, but I did not check it for correctness.

{
    "ds": {
        "LaborDtl": [
            {
                "Company": "99927",
                "EmployeeNum": "100",
                "LaborHedSeq": 9909909,
                "LaborDtlSeq": 9909909,
                "LaborType": "P",
                "LaborTypePseudo": "P",
                "JobNum": "P6B-test",
                "AssemblySeq": 0,
                "OprSeq": 10,
                "LaborHrs": 0,
                "BurdenHrs": 0,
                "LaborQty": 10,
                "Complete": true,
                "LaborRate": 60,
                "BurdenRate": 40,
                "OpComplete": true,
                "CompleteFlag": true,
                "LotNum": "MF1111106162024",
                "RowMod": "A"
            }
        ]
    }
}
1 Like

Can you just use the UpdateExt method API as it only requires a minimal dataset?

1 Like

I would assume, but I think you can do minimals on some updates.
Absolutely not sure.

He could certainly just leave the other tables empty.

Hell I don’t know, I live in function land.

1 Like

Closer… I get this error:

"HttpStatus": 400,
  "ReasonPhrase": "REST API Exception",
  "ErrorMessage": "Invalid operation code.",
  "ErrorType": "Ice.Common.BusinessObjectException",
  "ErrorDetails": [
    {
      "Message": "Invalid operation code.",
      "Type": "Error",
      "Table": "LaborDtl",
      "Program": "Epicor.RESTApi.Common.dll",
      "Method": "ThrowUpdateExtException",
      "ColumnNumber": 17,
      "LineNumber": 27

When posting this code:

{
  "Company": "99927",
  "EmployeeNum": "100",
  "LaborHedSeq": 9909909,
  "PayrollDate": "2024-06-17T18:02:17.578Z",
   "LaborDtls": [
    {
      "Company": "99927",
      "EmployeeNum": "100",
      "LaborHedSeq": 9909909,
      "LaborDtlSeq": 9909909,
      "LaborType": "P",
      "LaborTypePseudo": "P",
      "JobNum": "P6B_050223",
      "AssemblySeq": 0,
      "OprSeq": 10,
      "LaborHrs": 1,
      "BurdenHrs": 0,
      "LaborQty": 1,
      "Complete": true,
      "LaborRate": 0,
      "BurdenRate": 0,
      "PayrollDate": "2024-06-17T18:03:23.301Z",
      "LotNum": "MF1000006172024",
      "RowMod": "A"
      }
    ]    
}
Generally Helpful for New & Old Epicor Programmers

Code Syntax Highlighting in Posts

Genitive Indicis (Index)

Let’s share useful Functions! - Sharing Is Caring :slight_smile:

Let’s share useful (Programming) Resources

Kinetic Code Camp - Bring your skills, or lack thereof… :dumpster_fire:

Experts Corner

Code Review & Sharing

Look at the first section of what I just posted. :wink:


Try this (and maybe try it on UpdateExt?):

{
    "ds": {
        "LaborHed": [
            {
                "Company": "99927",
                "EmployeeNum": "100",
                "LaborHedSeq": 9909909,
                "PayrollDate": "2024-06-17T18:02:17.578Z"
            }
        ],
        "LaborDtls": [
            {
                "Company": "99927",
                "EmployeeNum": "100",
                "LaborHedSeq": 9909909,
                "LaborDtlSeq": 9909909,
                "LaborType": "P",
                "LaborTypePseudo": "P",
                "JobNum": "P6B_050223",
                "AssemblySeq": 0,
                "OprSeq": 10,
                "LaborHrs": 1,
                "BurdenHrs": 0,
                "LaborQty": 1,
                "Complete": true,
                "LaborRate": 0,
                "BurdenRate": 0,
                "PayrollDate": "2024-06-17T18:03:23.301Z",
                "LotNum": "MF1000006172024",
                "RowMod": "A"
            }
        ]
    }
}

Forewarned, I’m really not paying that much attention, so may not be right.
Got my own fires going on.