Get the Staff List from TasQ.
URL:
https://jobapi.tasq.com.au/api/Q6/GetStaffList?Jsonlogin={“LoginName”:”testapi@tasq.com.au”,”ClientIP”:null,”Password”:”test123.”,”MobileDeviceToken”:null,”WebApiTOKEN”:”b3b777b0-c7af-458d-be64-b3d6d760177f”}
Supports:
GET
Attribute Details:
Json login | String |
JSON Sample Code
Return Value:
{
"ActionCode": null,
"IsSuccessed": "YES",
"ErrorMessage": "",
"ReturnData": {
"StaffList": [
{
"CompanyID": "0000001-00293D54-5E72-447C-A2F5-082C59C14DCD-JOB",
"UserID": "f3a6c823-57f4-4993-b6eb-6eecfc419586",
"UserName": "wulong yang",
"FirstName": "wulong",
"LastName": "yang",
"Mobile": "0411208787",
"LoginEmail": "yange@uniware.com.au",
"Password": "richman58#",
"OldPassword": null,
"NewPassword": null,
"IsMain": true,
"CreateDate": "2013-02-28T00:30:33.39",
"UserRoleID": null,
"UserRoleName": "",
"ShownInDispatchJob": true,
"StaffPhoto":…
,
"RoundingBy": "15Mins",
"ShiftStatus": "ClockOff"
},
{
"CompanyID": "0000001-00293D54-5E72-447C-A2F5-082C59C14DCD-JOB",
"UserID": "5b2c119d-08dc-402b-bd57-eaa60eb8b5e1",
"UserName": "ze lei",
"FirstName": "ze",
"LastName": "lei",
"Mobile": "17671758651",
"LoginEmail": "a@uniware.com.au",
"Password": "richman58.",
"OldPassword": null,
"NewPassword": null,
"IsMain": false,
"CreateDate": "2017-02-14T23:53:47",
"UserRoleID": null,
"UserRoleName": "",
"ShownInDispatchJob": true,
"StaffPhoto":… ,
"RoundingBy": "30Mins",
"ShiftStatus": null
},
…
}
C# Sample Code
public static string GetStaffList (string Url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Method = "GET";
request.ContentType = "application/json";
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
string retString = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();
if (response != null)
{
response.Close();
}
if (request != null)
{
request.Abort();
}
return retString;
}
JavaScript Sample Code
function GetStaffList () {
$.ajax({
type: "Get",
url: "https://jobapi.tasq.com.au/api/Q6/GetStaffList",
data: {
…
},
dataType: "json",
success: function (data) {
console.dir(data)
},
error: function (e) {
console.dir(e)
}
});
}
Java Sample Code
private static void GetStaffList(String path){
try {
URL url = new URL(path);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
InputStreamReader in = new InputStreamReader(connection.getInputStream());
BufferedReader reader = new BufferedReader(in);
String line = "";
StringBuilder result = new StringBuilder();
while ((line = reader.readLine()) != null) {
result.append(line);
}
reader.close();
connection.disconnect();
System.out.println(result);
}
} catch (IOException e) {
e.printStackTrace();
}
}
Swift Sample Code
func GetStaffList ()
{
let loginDetail: LoginDetail = LoginDetail()
let UrlString = TASQSampleCommonLibrary.TASQApiUrl
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?
let jasonLoginDeail = TASQSampleCommonLibrary.convertDictionaryToJSONData(dicData: arrayData as [String : AnyObject])
let attachedURL: String = ""
let EncodeAttachedURL = (jasonLoginDeail + attachedURL).addingPercentEncoding(withAllowedCharacters: .urlHostAllowed )! as String
let url : String = UrlString + "Item/GetStaffList?Jsonlogin=" + EncodeAttachedURL
let replacedUrlString = url.replacingOccurrences(of: "\\", with:"" )
let request = NSMutableURLRequest(url: NSURL(string: replacedUrlString)! as URL, cachePolicy: NSURLRequest.CachePolicy.reloadIgnoringLocalCacheData, timeoutInterval: 300)
request.httpMethod = "GET"
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()
}
}