You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mule4使用Workday HR连接器POST工作邮箱遇验证错误求助

Workday邮箱同步验证错误排查

问题背景

在Mule4中开发API,需将用户工作邮箱POST同步至Workday,使用Workday Human Resources Connector的Change_Work_Contact_Information操作,但持续触发验证错误。

错误信息

核心错误提示

Subject person must have exactly one primary work email address in order to have non-primary entries. The primary contact information may be either previously entered or included within this request.

完整错误日志

SoapFault{faultCode={http://schemas.xmlsoap.org/soap/envelope/}Client.validationError, subCode=null, detail='<?xml version="1.0" encoding="UTF-8"?><detail><wd:Validation_Fault xmlns:wd="urn:com.workday/bsvc"><wd:Validation_Error><wd:Message>Subject person must have exactly one primary work email address in order to have non-primary entries. The primary contact information may be either previously entered or included within this request.</wd:Message><wd:Detail_Message>Element 6$111091 Restricted by 103$71804</wd:Detail_Message><wd:Xpath>/wd:Change_Work_Contact_Information_Request[1]/wd:Change_Work_Contact_Information_Data[1]/wd:Person_Contact_Information_Data[1]/wd:Person_Email_Information_Data[1]</wd:Xpath></wd:Validation_Error><wd:Validation_Error><wd:Message>Email Data and Usage Data elements are required unless email is being deleted.</wd:Message><wd:Detail_Message>Element 6$111110 Restricted by 103$65597</wd:Detail_Message><wd:Xpath>/wd:Change_Work_Contact_Information_Request[1]/wd:Change_Work_Contact_Information_Data[1]/wd:Person_Contact_Information_Data[1]/wd:Person_Email_Information_Data[1]/wd:Email_Information_Data[1]</wd:Xpath></wd:Validation_Error></wd:Validation_Fault></detail>', reason='Validation error occurred. Subject person must have exactly one primary work email address in order to have non-primary entries. The primary contact information may be either previously entered or included within this request.', node='null', role='null'}

当前使用的Transform Message代码

%dw 2.0
output application/xml
ns ns0 urn:com.workday/bsvc
---
{
    ns0#Change_Work_Contact_Information_Request: {
        ns0#Change_Work_Contact_Information_Data: {
            ns0#Person_Reference: {
                ns0#ID @(ns0#"type": "Employee_ID"): payload.employeeId
            },
            ns0#Person_Contact_Information_Data: {
                ns0#Person_Email_Information_Data: {
                    ns0#Email_Information_Data: {
                        ns0#Email_Data: {
                            ns0#Email_Address: payload.email,
                            ns0#Email_Comment: p('workday.createEmailMessage') as String default ""
                        }
                    }
                }
            }
        }
    }
}

问题排查与修正方案

问题根源

请求体遗漏了Workday要求的两个必填配置:

  1. 邮箱主/次标记:Workday要求每个员工必须有且仅有一个主工作邮箱,请求中未指定该邮箱的主状态(Primary Flag)
  2. 邮箱使用数据:错误日志明确指出Email Data and Usage Data elements are required,当前请求缺少Email_Usage_Data节点,这是Workday定义邮箱用途(如工作邮箱)的必填项

修正后的请求体代码

以下代码添加了主邮箱标记和必填的使用数据,适用于设置该邮箱为员工的主工作邮箱场景:

%dw 2.0
output application/xml
ns ns0 urn:com.workday/bsvc
---
{
    ns0#Change_Work_Contact_Information_Request: {
        ns0#Change_Work_Contact_Information_Data: {
            ns0#Person_Reference: {
                ns0#ID @(ns0#"type": "Employee_ID"): payload.employeeId
            },
            ns0#Person_Contact_Information_Data: {
                ns0#Person_Email_Information_Data: {
                    // 添加主邮箱标记
                    ns0#Primary: true,
                    ns0#Email_Information_Data: {
                        ns0#Email_Data: {
                            ns0#Email_Address: payload.email,
                            ns0#Email_Comment: p('workday.createEmailMessage') as String default ""
                        },
                        // 添加必填的邮箱使用数据,指定为工作邮箱
                        ns0#Email_Usage_Data: {
                            ns0#Type_Reference: {
                                ns0#ID @(ns0#"type": "Communication_Usage_Type_ID"): "WORK"
                            }
                        }
                    }
                }
            }
        }
    }
}

操作正确性说明

使用Change_Work_Contact_Information操作是正确的,该操作专门用于修改员工的联系人信息(包括邮箱),无需更换连接器或操作。

内容的提问来源于stack exchange,提问作者ilya.fastiv

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 23:12:48