URL:
https://jobapi.tasq.com.au/api/Staff/EditLeave
Supports:
POST
Attribute Details:
Company Validate Info
Login Name | String | must |
Client IP | String | optional |
Password | String | must |
Mobile Device Token | String | optional |
Web Api TOKEN | Guid (36) | must |
Leave
Leave ID | Guid (36) | must |
Reference No. | String (50) | must |
Staff ID | Guid (36) | must |
Leave Type | Guid (36) | must |
Start Time | Date Time | must |
End Time | Date Time | must |
Total hours | Decimal (18.6) | must |
Has Approval | Boolean | must |
Is Deleted | Boolean | must |
Create Time UTC | Date Time | must |
Created By | String (100) | must |
Last Modified Time UTC | Date Time | must |
Last Modified By | String (100) | must |
Memo | String (200) | optional |
Leave Type Name | String (200) | optional |
JSON Sample Code:
{
"CompanyValidateInfo": {
"ClientIP": null,
"LoginName": "testapi@tasq.com.au",
"MobileDeviceToken": null,
"Password": "test123.",
"WebApiTOKEN": "b3b777b0-c7af-458d-be64-b3d6d760177f"
},
"Leave": {
"LeaveID": "ACBC85EA-AA9D-4DC9-9057-A00E0E619914",
"ReferenceNO": null,
"StaffID": "0AD4938D-0B26-44B6-8D3D-ECC08C792085",
"LeaveType": "588DFB60-04AD-41A5-B5F6-28355D65C5F2",
"StartTime": "2019-10-23T09:00:00",
"EndTime": "2019-10-23T09:30:00",
"Totalhours": 0.5,
"hasApproval": true,
"IsDeleted": false,
"CreateTimeUTC": "0001-01-01T00:00:00",
"CreatedBy": null,
"LastModifiedTimeUTC": "0001-01-01T00:00:00",
"LastModifiedBy": null,
"Memo": "456",
"LeaveTypeName": "LT1"
}
}
Return Value:
{
"ActionCode": "Edit",
"IsSuccessed": "YES",
"ErrorMessage": "Saved successfully!",
"ReturnData": "acbc85ea-aa9d-4dc9-9057-a00e0e619914"
}
C# Sample Code:
public static string EditLeave (string Url ,string content)
{
string result = "";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(Url);
req.Method = "POST";
req.ContentType = "application/json";
#region Add Post Param
byte[] data = Encoding.UTF8.GetBytes(content);
req.ContentLength = data.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
reqStream.Close();
}
#endregion
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
Stream stream = resp.GetResponseStream();
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();
}
return result;
}
JavaScript Sample Code
function EditLeave () {
$.ajax({
type: "Post",
url: " https://jobapi.tasq.com.au/api/Staff/EditLeave",
data: {
…
},
dataType: "json",
success: function (data) {
console.dir(data)
},
error: function (e) {
console.dir(e)
}
});
}
Java Sample Code:
private static void EditLeave(String json){
try {
URL url = new URL("https://jobapi.tasq.com.au/api/Staff/EditLeave");
HttpURLConnection con = (HttpURLConnection)url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json; charset=utf-8");
con.setRequestProperty("Accept", "application/json");
con.setDoInput(true);
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Connection", "Keep-Alive");
if (json != null){
byte[] writeBytes = json.getBytes("utf-8");
OutputStream outputStream = con.getOutputStream();
outputStream.write(writeBytes,0, writeBytes.length);
outputStream.flush();
outputStream.close();
}
if (con.getResponseCode() == HttpURLConnection.HTTP_OK){
InputStreamReader in = new InputStreamReader(con.getInputStream());
BufferedReader br = new BufferedReader(in);
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null){
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
} catch (IOException e) {
e.printStackTrace();
}
}
Swift Sample Code:
func EditLeave ()
{
let leave: Leave = Leave()
let UrlString = TASQSampleCommonLibrary.TASQApiUrl + "Staff/EditLeave"
let loginDetail: LoginDetail = LoginDetail()
var parameters = [String:AnyObject]()
var arrayData = [String:AnyObject]()
arrayData ["WebApiTOKEN"] = TASQSampleCommonLibrary.TASQApiTOKEN as AnyObject?
arrayData ["LoginName"] = loginDetail.LoginEmail! as AnyObject?
arrayData ["Password"] = loginDetail.LoginPassword! as AnyObject?
arrayData ["ClientIP"] = TASQSampleCommonLibrary.getIPAddresses() as AnyObject?
arrayData ["MobileDeviceToken"] = TASQSampleCommonLibrary.getMobileDeviceToken() as AnyObject?
parameters["CompanyValidateInfo"] = arrayData as AnyObject?
var leaveData = [String:AnyObject]()
leaveData["LeaveID"] = "" as AnyObject
leaveData["ReferenceNO"] = leave.ReferenceNO! as AnyObject?
leaveData["StaffID"] = leave.StaffID! as AnyObject?
leaveData["LeaveType"] = leave.LeaveType! as AnyObject?
leaveData["StartTime"] = leave.StartTime! as AnyObject?
leaveData["EndTime"] = leave.EndTime! as AnyObject?
leaveData["Totalhours"] = leave.Totalhours! as AnyObject?
leaveData["hasApproval"] = leave.hasApproval! as AnyObject?
leaveData["IsDeleted"] = leave.IsDeleted! as AnyObject?
leaveData["CreateTimeUTC"] = leave.CreateTimeUTC! as AnyObject?
leaveData["CreatedBy"] = leave.CreatedBy! as AnyObject?
leaveData["LastModifiedTimeUTC"] = leave.LastModifiedTimeUTC! as AnyObject?
leaveData["LastModifiedBy"] = leave.LastModifiedBy! as AnyObject?
leaveData["Memo"] = leave.Memo as AnyObject?
leaveData["Memo"] = leave.LeaveTypeName as AnyObject?
parameters["Leave"] = leaveData as AnyObject
let request = NSMutableURLRequest(url: NSURL(string: UrlString)! as URL, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 300)
let jsonString = TASQSampleCommonLibrary.convertDictionaryToJSONData(dicData: parameters)
print(jsonString)
request.httpBody = jsonString.data(using: String.Encoding.utf8, allowLossyConversion: true)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
do {
let config = URLSessionConfiguration.default
let session = URLSession(configuration: config)
let task = session.dataTask(with: request as URLRequest, completionHandler: {
(data, response, error) in
})
task.resume()
}
}