Reputation: 1
This is the JSON string i am passing to a POST request:
var data = {
"location": {
"value": {
"href": "http://localhost:8080/restful/objects/businessentities.Location/47"
}
},
"asset": {
"value": {
"href": "http://localhost:8080/restful/objects/businessentities.Asset/36"
}
}
}
The AngularJS resource code is:
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)); })
However i am getting a server response 422 (Unprocessable Entity) error:
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"
},
That same JSON string works successfully when used in Postman.
Upvotes: 0
Views: 149
Reputation: 1
I was able to solve this issue -- by using the own resource class, rather its resource instance.
Upvotes: 0