How can I communicate with the Kronos API?

Also,you need to make sure you have XML API access check in the Function Access Profile in Kronos.


You get that with the brower because the Kronos server only support POST requests and the Browser is issuing a GET Request. The reason for that is because Kronos requires an XML in the body and the POST is the most adecuate method to do so.

The way to access the Kronos XML API, is making a WebRequest to the URL you have with the Method set to POST like this:

HttpWebRequest reqFp = (HttpWebRequest)HttpWebRequest.Create(KronosServerUrl);
reqFp.Method = "POST";
reqFp.ContentType = "text/xml";

Note how the ContentType is also set to text/xml.


You can communicate with the Kronos API using XML POST requests.

The WFC v5.0 Developer's Toolkit Programmer's Guide1 provides a general guide for communicating with the Kronos API in various languages. The first chapter covers the XML API, which is how all API requests will be sent.

Logon Request

A standard XML logon request for Kronos WFC. This must be sent first before any other requests.

<Kronos_WFC version="1.0">
  <Request Object="System" Action="Logon" Username="ValidUsername" Password="ValidPassword"/>
</Kronos_WFC>

Response:

<Kronos_WFC version="1.0" TimeStamp="11/15/2017 3:35PM GMT-05:00">
    <Response Status="Success" Timeout="1800" PersonKey="123456" Object="System" Username="ValidUsername" Action="Logon" PersonNumber="112233">
    </Response>
</Kronos_WFC>

Logoff Request

This logoff request will end your active Kronos session.

<Kronos_WFC version="1.0">
  <Request Object="System" Action="Logoff"/>
</Kronos_WFC>

Pay Period Total Request

This request loads the Pay Period Total for employee 12345 between October 20th 2017 and October 27th 2017.

<Kronos_WFC version="1.0">
  <Request Action="Load">
    <Timesheet>
      <Employee>
        <PersonIdentity PersonNumber="12345"/>
      </Employee>
      <Period>
        <TimeFramePeriod PeriodDateSpan="10/20/2017 - 10/27/2017"/>
      </Period>
    </Timesheet>
  </Request>
</Kronos_WFC>

A full list of Kronos API tags can be found in the Workforce Timekeeping Developer Toolkit Reference Guide (requires login).


Your method of sending POST requests may vary depending on your language. However, the XML request format and API entry point (<ServerName>/wfc/XmlService) should apply to all languages.

Below is an example Python 3 script for sending a Kronos logon request:

import requests

url = "http://localhost/wfc/XmlService"
headers = {'Content-Type': 'text/xml'}
data = """<Kronos_WFC version = "1.0">
              <Request Object="System" Action="Logon" Username="SomeUsername" Password="SomePassword"/>
          </Kronos_WFC>"""

# Login to Kronos and print response
session = requests.Session()  # preserve login cookies across requests
response = session.post(url, data=data, headers=headers)
print(response.text)

Chapter 2 of the WFC Developer's Toolkit Programmer's Guide includes examples for sending XML requests in Java and Visual Basic. However, I recommend looking into a more up-to-date XML or HTTP requests library specific to whatever language you are using.


Helpful Resources

  • Workforce Timekeeper v8.0.16 Developer's Toolkit Reference Guide (requires login)
  • WFC v5.0 Developer's Toolkit Programmer's Guide
  • Documentation and Service Packs for Kronos Products (requires login)
  • WFC-API.js - JavaScript for sending XML requests to WFC API
  • TimeCardView - Open source web UI to the Kronos API
  • Kronos Community Forums

Footnotes:

1: The quoted documentation was originally written for Kronos WFC 5.0 (API 1.0). While later versions should use the same API, I cannot guarantee accuracy for other versions. (See XML API version 6.3 to 8.0 upgrade)