Hi,
Can anyone help me with Javascript post method? Before I am doing a web app I am testing Get and Post methods, with Get everything is ok, but Post does not work for me and I can not see where mistake is. So I am trying to Post “StartActivity”, seems everything goes well when I do this in swagger it creates new activity in epicor, but when I try the same in postman and javascript fetch I get an error:
{
"odata.error": {
"code": "",
"message": {
"lang": "en-US",
"value": "Unsupported Media Type"
}
}
}
My script looks like this:
function StartActivity(){
let link = "https://xxx/xxx/api/v1/Erp.BO.LaborSvc/Update";
let h = new Headers();
h.append('Accept', 'application/json');
let encoded = window.btoa('User:password');
let auth = 'Basic ' + encoded;
h.append('Authorization', auth );
let req = new Request(link, {
method: 'POST',
headers: h,
body: JSON.stringify({
"ds": {
"LaborHed": [
{
"Company": "SFU",
"EmployeeNum": "415",
"LaborHedSeq": 141422,
"PayrollDate": "2022-08-09T00:00:00",
"Shift": 123,
"ClockInDate": "2022-08-08T00:00:00",
"ClockInTime": 8.72,
"DspClockInTime": "08:43",
"ActualClockInTime": 8.72,
"ActualClockinDate": "2022-08-08T00:00:00",
"LunchStatus": "N",
"ActLunchOutTime": 0,
"LunchOutTime": 0,
"ActLunchInTime": 0,
"LunchInTime": 0,
"ClockOutTime": 0,
"DspClockOutTime": "",
"ActualClockOutTime": 0,
"PayHours": 0,
"FeedPayroll": false,
"TransferredToPayroll": false,
"LaborCollection": true,
"TranSet": "",
"ActiveTrans": true,
"ChkLink": "",
"BatchTotalHrsDisp": "",
"BatchHrsRemainDisp": "",
"BatchHrsRemainPctDisp": "",
"BatchSplitHrsMethod": "",
"BatchAssignTo": false,
"BatchComplete": false,
"BatchStartHrs": null,
"BatchEndHrs": null,
"BatchTotalHrs": 0,
"BatchHrsRemain": 0,
"BatchHrsRemainPct": 0,
"SysRevID": 110238777,
"SysRowID": "965b62cb-b6a1-4d7a-8866-cb04517c90a7",
"Imported": false,
"ImportDate": null,
"BatchMode": false,
"HCMPayHoursCalcType": "",
"EmpBasicShift": 123,
"EmpBasicSupervisorID": "472",
"GetNewNoHdr": false,
"HCMTotPayHours": 0,
"ImagePath": "empphoto/SFU/.bmp",
"LunchBreak": false,
"MES": false,
"PayrollValuesForHCM": "NON",
"TimeDisableDelete": false,
"TimeDisableUpdate": false,
"TotBurHrs": 0,
"TotLbrHrs": 0,
"WipPosted": false,
"DspPayHours": 0,
"FullyPosted": false,
"PartiallyPosted": false,
"HCMExistsWithStatus": false,
"PayrollDateNav": "2022-08-09T00:00:00",
"BitFlag": 0,
"EmployeeNumFirstName": "Justas",
"EmployeeNumName": "Justas Dagys",
"EmployeeNumLastName": "Dagys",
"HCMStatusStatus": "",
"PRSystHCMEnabled": false,
"ShiftDescription": "00:00 to 00:00",
"RowMod": ""
}
],
"LaborDtl": [
{
"Company": "SFU",
"EmployeeNum": "415",
"LaborHedSeq": 141422,
"LaborDtlSeq": 101707,
"LaborType": "P",
"LaborTypePseudo": "P",
"ReWork": false,
"ReworkReasonCode": "",
"JobNum": "FRM015162",
"AssemblySeq": 0,
"OprSeq": 30,
"JCDept": "PCL",
"ResourceGrpID": "90",
"OpCode": "PC D",
"LaborHrs": 0,
"BurdenHrs": 0,
"LaborQty": 0,
"ScrapQty": 0,
"ScrapReasonCode": "",
"SetupPctComplete": 0,
"Complete": false,
"IndirectCode": "",
"LaborNote": "",
"ExpenseCode": "ADM",
"LaborCollection": true,
"AppliedToSchedule": false,
"ClockInMInute": 36172125,
"ClockOutMinute": 36173565,
"ClockInDate": "2022-08-08T00:00:00",
"ClockinTime": 12.75,
"ClockOutTime": 24,
"ActiveTrans": true,
"OverRidePayRate": 0,
"LaborRate": 17,
"BurdenRate": 151.45,
"DspClockInTime": "12:45",
"DspClockOutTime": "00:00",
"ResourceID": "9001",
"OpComplete": false,
"EarnedHrs": 0,
"AddedOper": false,
"PayrollDate": "2022-08-09T00:00:00",
"PostedToGL": false,
"FiscalYear": 0,
"FiscalPeriod": 0,
"JournalNum": 0,
"GLTrans": true,
"JournalCode": "",
"InspectionPending": false,
"CallNum": 0,
"CallLine": 0,
"ServNum": 0,
"ServCode": "",
"ResReasonCode": "",
"WipPosted": false,
"DiscrepQty": 0,
"DiscrpRsnCode": "",
"ParentLaborDtlSeq": 0,
"LaborEntryMethod": "T",
"FiscalYearSuffix": "",
"FiscalCalendarID": "",
"BFLaborReq": false,
"ABTUID": "",
"ProjectID": "",
"PhaseID": "",
"RoleCd": "",
"TimeTypCd": "",
"PBInvNum": 0,
"PMUID": 0,
"TaskSetID": "",
"ApprovedDate": null,
"ClaimRef": "",
"QuickEntryCode": "",
"TimeStatus": "",
"CreatedBy": "",
"CreateDate": null,
"CreateTime": 0,
"ChangedBy": "",
"ChangeDate": null,
"ChangeTime": 0,
"ActiveTaskID": "",
"LastTaskID": "",
"CreatedViaTEWeekView": false,
"CurrentWFStageID": "",
"WFGroupID": "",
"WFComplete": false,
"ApprovalRequired": false,
"SubmittedBy": "",
"PBRateFrom": "",
"PBCurrencyCode": "",
"PBHours": 0,
"PBChargeRate": 0,
"PBChargeAmt": 0,
"DocPBChargeRate": 0,
"Rpt1PBChargeRate": 0,
"Rpt2PBChargeRate": 0,
"Rpt3PBChargeRate": 0,
"DocPBChargeAmt": 0,
"Rpt1PBChargeAmt": 0,
"Rpt2PBChargeAmt": 0,
"Rpt3PBChargeAmt": 0,
"Shift": 1,
"ActID": 0,
"DtailID": 0,
"ProjProcessed": false,
"AsOfDate": null,
"AsOfSeq": 0,
"JDFInputFiles": "",
"JDFNumberOfPages": "",
"BatchWasSaved": "",
"AssignToBatch": false,
"BatchComplete": false,
"BatchRequestMove": false,
"BatchPrint": false,
"BatchLaborHrs": 0,
"BatchPctOfTotHrs": 0,
"BatchQty": 0,
"BatchTotalExpectedHrs": 0,
"JDFOpCompleted": "",
"SysRevID": 0,
"SysRowID": "00000000-0000-0000-0000-000000000000",
"Downtime": false,
"RefJobNum": "",
"RefAssemblySeq": 0,
"RefOprSeq": 0,
"Imported": false,
"ImportDate": null,
"TimeAutoSubmit": false,
"BatchMode": false,
"BillServiceRate": 0,
"HCMPayHours": 0,
"EpicorFSA": false,
"DiscrepAttributeSetID": 0,
"LaborAttributeSetID": 0,
"ScrapAttributeSetID": 0,
"AllowDirLbr": true,
"ApprovalPhaseDesc": "",
"ApprovalPhaseID": "",
"ApprovalProjectDesc": "",
"ApprovalProjectID": "",
"ApprovedBy": "",
"ApprvrHasOpenTask": false,
"BaseCurrCodeDesc": "",
"BurdenCost": 0,
"CallCode": "",
"CapabilityDescription": "",
"CapabilityID": "",
"ChargeRate": 0,
"ChargeRateSRC": "",
"ChgRateCurrDesc": "",
"CompleteFlag": false,
"ContractCode": "",
"ContractNum": 0,
"DiscrepUOM": "vnt",
"DisLaborType": false,
"DisplayJob": "FRM015162",
"DisPrjRoleCd": true,
"DisTimeTypCd": true,
"DowntimeTotal": 0,
"DspChangeTime": "",
"DspCreateTime": "",
"DspTotHours": "",
"DtClockIn": null,
"DtClockOut": null,
"EfficiencyPercentage": 0,
"EmployeeName": "",
"EnableComplete": false,
"EnableCopy": false,
"EnableDiscrepQty": true,
"EnableInspection": false,
"EnableLaborQty": true,
"EnableNextOprSeq": false,
"EnablePrintTagsList": false,
"EnableRecall": false,
"EnableRecallAprv": false,
"EnableRequestMove": false,
"EnableResourceGrpID": true,
"EnableScrapQty": true,
"EnableSN": false,
"EnableSubmit": false,
"EndActivity": false,
"EnteredOnCurPlant": false,
"FSAAction": "",
"FSACallCode": "",
"FSAContractCode": "",
"FSAContractNum": 0,
"FSAEmpID": "",
"FSAEquipmentInstallID": 0,
"FSAEquipmentPartNum": "",
"FSAServiceOrderNum": 0,
"FSAServiceOrderResourceNum": 0,
"FSAWarrantyCode": "",
"FSComplete": false,
"GLTranAmt": 0,
"GLTranDate": null,
"HasAccessToRow": true,
"HasComments": false,
"HH": false,
"IntExternalKey": "",
"ISFixHourAndQtyOnly": false,
"JCSystReworkReasons": true,
"JCSystScrapReasons": true,
"JobOperComplete": false,
"JobType": "Manufacture",
"JobTypeCode": "MFG",
"LaborCost": 0,
"LaborUOM": "vnt",
"LbrDay": "",
"LbrMonth": "",
"LbrWeek": "",
"MES": true,
"MultipleEmployeesText": "1 Employee(s) are already working on this operation",
"NewDifDateFlag": 0,
"NewPrjRoleCd": "",
"NewRoleCdDesc": "",
"NextAssemblySeq": 0,
"NextOperDesc": "",
"NextOprSeq": 0,
"NextResourceDesc": "",
"NonConfProcessed": false,
"NotSubmitted": false,
"OkToChangeResourceGrpID": false,
"PartDescription": "",
"PartNum": "SFF01097",
"PBAllowModify": false,
"PendingApprovalBy": "",
"PhaseJobNum": "",
"PhaseOprSeq": 0,
"PrintNCTag": false,
"PrjUsedTran": "",
"ProdDesc": "",
"ProjPhaseID": "",
"RequestMove": false,
"ResourceDesc": "",
"RoleCdDisplayAll": false,
"ScrapUOM": "vnt",
"SentFromMES": false,
"StartActivity": true,
"TimeDisableDelete": false,
"TimeDisableUpdate": false,
"TreeNodeImageName": "",
"UnapprovedFirstArt": false,
"WarrantyCode": "",
"WeekDisplayText": "",
"PCID": "",
"EnablePCID": false,
"OutputBin": "",
"OutputWarehouse": "",
"EnableLot": false,
"LotNum": "",
"PrintPCIDContents": false,
"HasAttachments": false,
"AttrClassID": "",
"DiscrepAttributeSetDescription": "",
"DiscrepAttributeSetShortDescription": "",
"ScrapAttributeSetDescription": "",
"ScrapAttributeSetShortDescription": "",
"LaborAttributeSetDescription": "",
"LaborAttributeSetShortDescription": "",
"DisableRecallAndDelete": false,
"RoleCdList": "",
"RowSelected": false,
"AppointmentStart": null,
"AppointmentEnd": null,
"AppointmentTitle": "",
"TemplateID": "",
"BitFlag": 0,
"DiscrpRsnDescription": "",
"EmpBasicLastName": "Dagys",
"EmpBasicFirstName": "Justas",
"EmpBasicName": "Justas Dagys",
"ExpenseCodeDescription": "ADM",
"HCMIntregationHCMEnabled": false,
"HCMStatusStatus": "",
"IndirectDescription": "",
"JCDeptDescription": "Dažymas / Powder coating Dep.",
"JobAsmblPartNum": "SFF01097",
"JobAsmblDescription": "LOW VOLTAGE MOUTING PL, FUSE",
"MachineDescription": "Dažymas / PCL 1",
"OpCodeOpDesc": "DAŽYMAS",
"OpDescOpDesc": "DAŽYMAS",
"PayMethodType": 0,
"PayMethodSummarizePerCustomer": false,
"PayMethodName": "",
"PhaseIDDescription": "",
"ProjectDescription": "",
"ResourceGrpDescription": "Dažymas / Powder coating",
"ResReasonDescription": "",
"ReWorkReasonDescription": "",
"RoleCdRoleDescription": "",
"ScrapReasonDescription": "",
"ShiftDescription": "",
"TimeTypCdDescription": "",
"RowMod": "A"
}
]
}
})
})
fetch(req)
.then(res=>res.json())
}