0
同样失败这是JSON字符串我传递到POST请求:JSON字符串获取邮差正确解析,但在JavaScript
var data = {
"location": {
"value": {
"href": "http://localhost:8080/restful/objects/businessentities.Location/47"
}
},
"asset": {
"value": {
"href": "http://localhost:8080/restful/objects/businessentities.Asset/36"
}
}
}
的AngularJS资源代码:
var AuditItemCreate = $resource(
apiUrl + '/restful/services/domainapp.dom.BusinessEntities.AuditItemMenu/actions/create/invoke/');
var a2 = new AuditItemCreate();
a2.$save(data)
.then(function(res) { console.log("success") })
.catch(function(req) { console.log("error saving obj: " + JSON.stringify(req, null, 4)); })
然而我得到一个服务器响应422(不可处理的实体)错误:
error saving obj: {
"data": {
"asset": {
"value": "{\"value\":{\"href\":\"http://localhost:8080/restful/objects/businessentities.Asset/36\"}}",
"invalidReason": "Expected a link (because this object's type is not a value) but found no 'href'"
},
"location": {
"value": "{\"value\":{\"href\":\"http://localhost:8080/restful/objects/businessentities.Location/47\"}}",
"invalidReason": "Expected a link (because this object's type is not a value) but found no 'href'"
},
"x-ro-invalidReason": "Mandatory"
},
相同的JSON字符串工作s在Postman中使用时会成功。