I need to send a json array to a soothing api from my angularjs application. I use ngresources for this. Since then, I have been removed to publish and place one object without problems, but now I need to send an array of objects, and I can not.
I tried to make a call from an external leisure application and it works fine, but this is not possible from my angular application. I have a trie to parse an object with JSON.stringify, but still not working. I set the header to 'Content-Type': 'application / json' as well as in $ resources.
This is how I do negresource:
.factory('AddSignosClinicos', function ($resource) { return $resource(dondeapuntar + "/Rest/Pacientedatossignosclinicos.svc/pACIENTEDATOSSIGNOSCLINICOSList/Add", {}, { create: { method: "POST", headers: { 'Content-Type': 'application/json', params: {} } } }); })
And this is how I call the function:
var objeto = JSON.stringify(SignosClinicosGuardar); var signosClinicosService = new AddSignosClinicos(objeto); signosClinicosService.$create().then(function () {});
I created the console.log of the objeto object and is the correct json array.
Any idea?
Thank you very much
EDIT
I tried the $ http component for the mail request and it will work! I do not understand why it does not work with ngResources, this is my code for $ http:
$http({ url: 'http://localhost:1046/Rest/Pacientedatossignosclinicos.svc/pACIENTEDATOSSIGNOSCLINICOSList/Add', method: "POST", data: SignosClinicosGuardar, headers: { 'Content-Type': 'application/json; charset=UTF-8' } });