Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →Query Workday Data Using the OData SDK for PHP
You can use the API Server and the OData PHP SDK to easily consume Workday entities in PHP by modeling them as objects.
The CData API Server, when paired with the ADO.NET Provider for Workday, exposes Workday data (or data from any of 200+ other ADO.NET Providers) as Web services. You can follow the procedure below to work with Workday data as PHP objects.
About Workday Data Integration
CData provides the easiest way to access and integrate live data from Workday. Customers use CData connectivity to:
- Access the tables and datasets you create in Prism Analytics Data Catalog, working with the native Workday data hub without compromising the fidelity of your Workday system.
- Access Workday Reports-as-a-Service to surface data from departmental datasets not available from Prism and datasets larger than Prism allows.
- Access base data objects with WQL, REST, or SOAP, getting more granular, detailed access but with the potential need for Workday admins or IT to help craft queries.
Users frequently integrate Workday with analytics tools such as Tableau, Power BI, and Excel, and leverage our tools to replicate Workday data to databases or data warehouses. Access is secured at the user level, based on the authenticated user's identity and role.
For more information on configuring Workday to work with CData, refer to our Knowledge Base articles: Comprehensive Workday Connectivity through Workday WQL and Reports-as-a-Service & Workday + CData: Connection & Integration Best Practices.
Getting Started
Set Up the API Server
Follow the steps below to begin producing secure Workday OData services:
Deploy
The API Server runs on your own server. On Windows, you can deploy using the stand-alone server or IIS. On a Java servlet container, drop in the API Server WAR file. See the help documentation for more information and how-tos.
The API Server is also easy to deploy on Microsoft Azure, Amazon EC2, and Heroku.
Connect to Workday
After you deploy the API Server and the ADO.NET Provider for Workday, provide authentication values and other connection properties needed to connect to Workday by clicking Settings -> Connections and adding a new connection in the API Server administration console.
To connect to Workday, users need to find the Tenant and BaseURL and then select their API type.
Obtaining the BaseURL and Tenant
To obtain the BaseURL and Tenant properties, log into Workday and search for "View API Clients." On this screen, you'll find the Workday REST API Endpoint, a URL that includes both the BaseURL and Tenant.
The format of the REST API Endpoint is: https://domain.com/subdirectories/mycompany, where:
- https://domain.com/subdirectories/ is the BaseURL.
- mycompany (the portion of the url after the very last slash) is the Tenant.
Using ConnectionType to Select the API
The value you use for the ConnectionType property determines which Workday API you use. See our Community Article for more information on Workday connectivity options and best practices.
API | ConnectionType Value |
---|---|
WQL | WQL |
Reports as a Service | Reports |
REST | REST |
SOAP | SOAP |
Authentication
Your method of authentication depends on which API you are using.
- WQL, Reports as a Service, REST: Use OAuth authentication.
- SOAP: Use Basic or OAuth authentication.
See the Help documentation for more information on configuring OAuth with Workday.
You can then choose the Workday entities you want to allow the API Server access to by clicking Settings -> Resources.
Additionally, configure the API Server for compatibility with the OData SDK for PHP: Click Server -> Settings and in the OData section set Default Version to 2.0.
Authorize API Server Users
After determining the OData services you want to produce, authorize users by clicking Settings -> Users. The API Server uses authtoken-based authentication and supports the major authentication schemes. You can authenticate as well as encrypt connections with SSL. Access can also be restricted based on IP address; by default, only connections from the local machine are allowed.
For simplicity, we will authenticate to the API Server by setting the authtoken in the URL. This is not enabled by default; you will need to add the following lines to the API Server configuration file, settings.cfg.
[Application]
AllowAuthTokenInUrl = true
The settings.cfg file is located in the data directory. In the .NET edition, the data directory is the app_data folder under the www folder. In the Java edition, the data directory's location depends on the operation system:
- Windows: C:\ProgramData\CData\Workday\
- Unix or Mac OS X: ~/cdata/Workday/
Work with Workday Entities as PHP Objects
Follow the steps below to use the ODataPHP SDK to create a proxy class that will connect to the Web services exposed by the API Server.
-
Pass the URL to a command like the one below:
php C:\PHPLib\ODataphp\PHPDataSvcUtil.php /uri=https://your-server:8032/api.rsc/@your-authtoken/ /out=C:\PHPLib\ODataphp\WorkdayEntities.php
The preceding command defines classes from the metadata returned in the response from the OData endpoint, then outputs the class definitions to the specified folder.
Both the API Server and the OData SDK for PHP support forms and Windows authentication. The API Server uses authtokens to authenticate users authorized to access the OData endpoint. You can supply authtokens in HTTP Basic authentication or append them to the OData URL.
You can configure authorized users in the Settings -> Users section of the API Server administration console.
-
You can now start accessing Workday data using an object-oriented interface in PHP. The code below creates a record of the Workers table and then retrieves the live data, showing the newly created record.
require_once 'WorkdayEntities.php'; try{ $svc = new CData(); $workers = new Workers(); $workers->Legal_Name_Last_Name = 'Morgan'; $svc->AddToWorkers($workers); $svc->SetSaveChangesOptions(SaveChangesOptions::None); $svc->SaveChanges(); $response = $svc->workers()->Execute(); foreach($response->Result as $workers) echo $workers->Worker_Reference_WID.""; } catch (Exception $e) { //catch errors from the API Server echo $e->getError(), "\n"; }