REST service that inserts Timecard data
using System.Net;
using System.Text;
string uri = "https://fusion.superion.com/FusionOSServices/v1/ONESolution/Payroll/Timecards";
StringBuilder sb = new StringBuilder();
sb.AppendLine("[ ");
sb.AppendLine(" { ");
sb.AppendLine(" \"EmpId\":\"E0001\", ");
sb.AppendLine(" \"TranDt\":\"3/15/2017\", ");
sb.AppendLine(" \"Hrs\": 4, ");
sb.AppendLine(" \"Cdh\": \"3001\" ");
sb.AppendLine(" }, ");
sb.AppendLine(" { ");
sb.AppendLine(" \"EmpId\":\"E0002\", ");
sb.AppendLine(" \"TranDt\":\"3/15/2017\", ");
sb.AppendLine(" \"Hrs\": 4.25, ");
sb.AppendLine(" \"Cdh\": \"3001\" ");
sb.AppendLine(" } ");
sb.AppendLine("] ");
string data = sb.ToString();
using (WebClient req = new WebClient())
{
string stringResult = req.UploadString(new Uri(uri), "PUT", data);
// TODO
}
{
"RequestResponse": {
"Count": "2",
"DATA": null
}
sample with errors
{
"RequestResponse": {
"Count": "0",
"DATA": {
"Error": [
{
"@Item": "0",
"#text": "this is a sample error"
},
{
"@Item": "47",
"#text": "this is a sample error"
}
]
}
}
}
}
Expected input is a JSON array of objects, with each object containing one timecard entry. Allowed elements in each timecard entry are EmpId, TranDt, Cdh, Hrs, BatchId, PerCc, Sort, Group, Misc1, Misc2, Misc3, Misc4, Misc5, BegDt, RecType, NumCd, RingIn, RingOut, Rate, Amt, RateCd1, RateCd2, RateCd3, RateCd4, RateCd5, ReasonCd, OvrHrs, OvrRt, OvrAmt, OvrNum, Status, JobNo, Orig, Text, Link, EmpId2, Account, Wo, PayClass, Pos, Step, GlGr, GlKey, GlObj, JlGr, JlKey, JlObj, User1, User2, User3, User4, User5, User6, User7, User8, User9, AprvCd1, AprvCd2, AprvCd3, AprvCd4, AprvCd5, TranOp, SystemId, ProcessedDt, MiscDesc, WfCode, Eqno, Ifpy980Flag. While all of these elements are optional, the first four, EmpId, TranDt, Cdh and Hrs are recomended. Elements included in the JSON but not in this list will be ignored. Hour values with more than 5 decimal places of precision will be accepted, but truncated. e.g. 5.123456 will be accepted as 5.12345 The response from this call will include the number of inserted records and a list of errors, if any. Any error will result in the entire submission being rejected and the count reported will be zero.