Export payroll information

URL: GET /api/v1/payrollexport/<payroll_export_format>[?startdate=<start_date>][&startdate=<end_date>]

Content: None

Returns: The payroll information for the given date range that is formatted per the specification of the specified payroll_export_format. If the start_date or end_date is not provided, then today’s date will be used. The payroll_export_format must refer to a Payroll Export Format that is already defined in the schedule.

Example Code

public string ExportPayroll(string accessToken, string payrollExportFormat)
{

    string shift = string.Empty;

    // Create web request to call API (be sure to add access token to request header)
    var webRequest = (HttpWebRequest) WebRequest.Create(@"https://app.snapschedule365.com/api/v1/payrollexport/" + payrollExportFormat);
    webRequest.Method = "GET";
    webRequest.Accept = @"application/json";

	webRequest.Headers.Add("Authorization", "Bearer " + accessToken);
    webRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;

    try
    {
        using (WebResponse webResponse = webRequest.GetResponse())
        {
            // If the web response is OK, then read the reply and display the payroll information
            if (( (HttpWebResponse) webResponse).StatusCode == HttpStatusCode.OK)
            {
                var reader = new StreamReader(webResponse.GetResponseStream());
                string payrollInformation = reader.ReadToEnd();

        	Console.WriteLine(payrollInformation);

                reader.Close();
            }
        }
    }
    catch (WebException e)
    {
        // An error occurred in the call -- handle appropriately
        Console.WriteLine(e);
    }

    return shift;

}
function getFirstShiftDescription(accessToken, payrollExportFormat, startDate, endDate, callback)
{
	// URL of API to invoke
	var serviceUrl = "https://app.snapschedule365.com/api/v1/payrollexport/" + encodeURIComponent(payrollExportFormat) + "?startDate=" + startDate.toDateString() + "&endDate=" + endDate.toDateString();

	// Create the request
	var request = new XMLHttpRequest();

	// Build the request
	request.open("GET", serviceUrl, true);
	request.setRequestHeader("accept", "application/json");
	
	// Add access token to request
	request.setRequestHeader("Authorization", "Bearer " + accessToken);  

	// Set up request status handler to invoke the callback function when complete
	request.onreadystatechange = function()
	{
		if (request.readyState == 4)
		{
			if (request.status == 200)
			{
				var payrollInformation = request.responseText;

				callback(payrollInformation);
			}
			else
			{
				alert("HTTP status: " + request.status + "\n" + request.responseText);
			}
		}
	}

	// Send the request
	request.send();
}