使用Workday API删除员工工作邮箱遇ID参数错误求助
我正在用Workday API删除员工的工作邮箱地址,但删除操作要求传入该邮箱字段的唯一引用ID。文档提到Get_Change_Work_Contact_Information_Request服务可作为Change_Work_Contact_Information_Request服务的输入,但实际使用时遇到了问题。
目前我将Get_Change_Work_Contact_Information_Request构造成数组$idrequest,并直接传入Change_Work_Contact_Information_Request的ID字段中,得到以下错误:
Validation error occurred. Invalid ID value. 'Array' is not a valid ID value for type = 'Email_ID'
我的代码如下:
$idrequest = [ 'Get_Change_Work_Contact_Information_Request' => [ 'Request_References' => [ 'Person_Reference' => [ 'ID' => ['_' => "{$empid}", 'type' => 'Employee_ID' ] ] ] ] ]; $params = [ 'Change_Work_Contact_Information_Request' => [ 'Business_Process_Parameters' => [ 'Auto_Complete' => '1', 'Run_Now' => '1' ], 'Change_Work_Contact_Information_Data' => [ 'Person_Reference' => [ 'ID' => ['_' => "{$empid}", 'type' => 'Employee_ID' ] ], 'Event_Effective_Date' => "{$date}", 'Person_Contact_Information_Data' => [ 'Person_Email_Information_Data' => [ 'Email_Information_Data' => [ 'Delete' => 'True', 'Email_Reference' => [ 'ID' => ['_' => "{$idrequest}", 'type' => 'Email_ID' ] ], ] ] ] ] ] ];
问题原因
你错误地把Get_Change_Work_Contact_Information_Request的请求结构体直接当作邮箱ID传入了。这个接口的作用是调用后获取员工的邮箱信息(包括唯一的Email_ID),而不是直接作为ID值使用。错误提示里的'Array'就是因为你把整个数组塞给了需要字符串ID的字段。
解决步骤
- 先调用
Get_Change_Work_Contact_Information_Request接口,传入员工ID,从返回结果中提取出要删除的工作邮箱对应的Email_ID(这是一个字符串类型的唯一标识)。 - 将提取到的
Email_ID字符串填入删除请求的对应字段,替换掉原来的$idrequest数组。
修正后的代码示例
// 1. 先调用Get接口获取Email_ID(这里假设你已经通过Workday客户端完成调用,得到了$emailId字符串) $emailId = "从Get接口返回结果中提取的Email_ID值"; // 2. 构造删除请求 $params = [ 'Change_Work_Contact_Information_Request' => [ 'Business_Process_Parameters' => [ 'Auto_Complete' => '1', 'Run_Now' => '1' ], 'Change_Work_Contact_Information_Data' => [ 'Person_Reference' => [ 'ID' => ['_' => "{$empid}", 'type' => 'Employee_ID' ] ], 'Event_Effective_Date' => "{$date}", 'Person_Contact_Information_Data' => [ 'Person_Email_Information_Data' => [ 'Email_Information_Data' => [ 'Delete' => 'True', 'Email_Reference' => [ 'ID' => ['_' => $emailId, 'type' => 'Email_ID' ] ], ] ] ] ] ] ];
注意:调用Get_Change_Work_Contact_Information_Request时,返回结果里的邮箱信息会包含每个邮箱的ID(类型为Email_ID),你需要根据邮箱类型(比如工作邮箱)筛选出对应的ID值。
内容的提问来源于stack exchange,提问作者Stephen Brinkman

