BACK

CAQapi, API, Swagger


Used especially to visualize system data in other systems or use the Palstat mobile application, which operates via the API itself and can be installed on Android and iOS mobile phones. Client requests are handled through the IIS server over HTTPS, optionally HTTP through a structured request and JSON response format.

 

  • Option of data visualization in respective external system.
  • Intended for IT professionals with experience of working with API.
  • We offer customers the possibility support when implementing (C#,ASP a PHP) environments
  • Connection to the Palstat CAQ system via the API is available to all customers upon purchase of the required LICence.

 

Example of basic communication with API

Individual objects are available after installing PalstatAPi on the page "www.mojeapi.com/PalstatApi/map/" where you can see a list of available components that can query system data. Currently, the API works in one direction, so read-only. There are only limited write-back options throughout the API, meaning it is always recommended to consult with our company.
 

PHP

The following example reads data from an object https://server.company.com/CAQapi/PAL/SystemInfo/,which returns information about the LICence used.


$cfg['api_user'] = 'definujte v Palstat CAQ';
$cfg['api_pass'] = 'definujte v Palstat CAQ';
$cfg['api_site'] = 'https://server.company.com/PalstatApi/';


/// pres CURL cteni dat z naseho Webserveru
function api_read($url){
	global $cfg;

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,$url);
	curl_setopt($ch, CURLOPT_USERAGENT, "API Palstat Connector by LH / Curl");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
	curl_setopt($ch, CURLOPT_TIMEOUT, 100); // protect IIS
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_USERPWD, $cfg['api_user'].":".$cfg['api_pass']);
	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); 
	curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);


	$response = curl_exec($ch);
	if ( $response === false ){ // zachyti connection error
		echo 'Curl error: ' . curl_error($ch).' - '.$url;
		exit;
	}

	curl_close($ch);
	return $response;
}

//// CTEME LIC INFO
$json = api_read($cfg['api_site'].'PAL/SystemInfo/'); 
$obj = json_decode($json,true);
$runtime['api']['CustomerName'] = $obj['CustomerName'];
$runtime['api']['DatabaseId'] = $obj['DatabaseId'];
$runtime['api']['CustomerDivisionName'] = $obj['CustomerDivisionName'];


echo "
API OBJECT: PAL/SystemInfo/

CustomerName: ".$runtime['api']['CustomerName']."
DatabaseId: ".$runtime['api']['DatabaseId']."
CustomerDivisionName: ".$runtime['api']['CustomerDivisionName']."
";


C#

The following example reads data from an object https://server.company.com/PalstatApi/LAB/Inspections/, which returns information from the laboratory module.

private HttpClient client;
private string serverUri = "http://server.company.com";
private string baseUri = "/PalstatApi";


public void CreateClient()
{
	client = new HttpClient() { BaseAddress = new Uri(serverUri) };
	var base64String = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{AppSettings.Login}:{AppSettings.Password}"));
	client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64String);
}

public async Task GetData(string path, string parameters)
{
	string uri = baseUri + path;
	if (!String.IsNullOrEmpty(parameters)) uri += "?" + parameters;
	var request = new HttpRequestMessage(HttpMethod.Get, uri);

	var resp = await client.SendAsync(request);
	if (resp.IsSuccessStatusCode)
	{
		return await resp.Content.ReadAsStringAsync();
	}
	else
	{
		throw new Exception("Error");
	}
}
        
public async Task GetInspection(string number)
{
	string uri = "/LAB/Inspections/" + number;
	var data = await GetData(uri, null);
	return JsonConvert.DeserializeObject(data);
}

public class LabInspectionModel
{
        public string Number { get; set; }
        public int State { get; set; }
        public string LabCode { get; set; }
        public string LabName { get; set; }
        public string PartNumber { get; set; }
        public string PartChange { get; set; }
        public string SupplierCode { get; set; }
        public string CustomerCode { get; set; }
        public string Specification { get; set; }
        public string Description { get; set; }
        public string SourceName { get; set; }
        public string TypeCode { get; set; }
        public string TypeName { get; set; }
        public int Priority { get; set; }
        public double? Amount { get; set; }
        public double? Price { get; set; }
        public string Currency { get; set; }
        public double? InspectTime { get; set; }
        public String CreatedBy { get; set; }
        public DateTime? CreatedDate { get; set; }
        public DateTime? SupplyDate { get; set; }
        public String PlannedBy { get; set; }
        public DateTime? PlannedStart { get; set; }
        public DateTime? PlannedEnd { get; set; }
        public String ProcessBy { get; set; }
        public string ProcessorCode { get; set; }
        public DateTime? ProcessStart { get; set; }
        public DateTime? ProcessEnd { get; set; }
        public int? ResultValue { get; set; }
        public string ResultName { get; set; }
        public string Note { get; set; }
}

 

https://www.palstat.cz/