angularjs - JSON string gets parsed correctly in Postman but the same fails in JavaScript -
this json string passing 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 getting server response 422 (unprocessable entity) error:
error saving obj: { "data": { "asset": { "value": "{\"value\":{\"href\":\"http://localhost:8080/restful/objects/businessentities.asset/36\"}}", "invalidreason": "expected link (because object's type not value) found no 'href'" }, "location": { "value": "{\"value\":{\"href\":\"http://localhost:8080/restful/objects/businessentities.location/47\"}}", "invalidreason": "expected link (because object's type not value) found no 'href'" }, "x-ro-invalidreason": "mandatory" },
that same json string works when used in postman.
i able solve issue -- using own resource class, rather resource instance.
Comments
Post a Comment