【发布时间】:2019-08-13 04:19:08
【问题描述】:
我创建了一个新的芭蕾舞演员类型如下。
const string GENERAL="GENERAL";
const string SECURITY="SECURITY";
type INCIDENT_TYPE GENERAL|SECURITY;
public type incidentNotification record {
string title;
INCIDENT_TYPE incidentType;
};
一旦我发送一个 POST 请求来创建一个新的事件通知,sendIncident 方法就会被执行。
public function sendIncident (http:Request req, incidentNotification sendIncidentBody) returns http:Response {}
与请求正文一起发送的 json 负载如下。
{
"title":"title",
"incidentType": "SECURITY"
}
但是当我用http请求发送那个json时,它给出了错误
数据绑定失败:读取有效负载时出错:映射时出错 “incidentType”:不兼容的类型:预期 'janaka/incident-reporting-service:0.0.1:$anonType$4|janaka/incident-reporting-service:0.0.1:$anonType$5', 找到'字符串'
如何解决这个错误?
【问题讨论】:
-
你能分享一些关于这个问题的背景吗?资源函数的示例代码将用作 HTTP 数据绑定功能,应该与资源函数一起使用。
标签: incompatibletypeerror ballerina