When making a REST API call in CodeIgniter, I encountered an issue with the array format being sent to the server:
[{"PMcolor":"Azul tostado","PMpartes":"Un poquito de las orjeas y un bigote a lo Dali, quizas le alegre la cara","PMcosteTotal":"445"}]:
The object I am working with is:
myobject = {PMcolor: "Azul tostado", PMpartes: "Un poquito de las orjeas y un bigote a lo Dali, quizas le alegre la cara", PMcosteTotal: "445" };
I have tried the following methods for POST requests:
1)
$scope.datosEnviar = [];
$scope.datosEnviar.push(myobject);
var config={ //this works, DO NOT CHANGE, this is for post method
method:"POST",
url:"http://localhost/APIREST/controllersencillo/",
params: {tabla : "PintaMonas"}
,data: $scope.datosEnviar,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}
2)
var config={ //this works, DO NOT CHANGE, this is for post method
method:"POST",
url:"http://localhost/APIREST/controllersencillo/",
params: {tabla : "PintaMonas"} //with id update, without id insert
,data: myobject,
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
}