suthagar23
(Suthagar Kailayapathy)
June 1, 2017, 12:26pm
1
Can someone help me to solve this AngularJS problem?
Another way, If I use $http POST method like this,
app.controller('MyCtrl', ['$scope','$http', function ($scope,$http) {
$scope.uploadPic = function(file) {
$http({
method: 'POST',
url: 'http://localhost:8080/openmrs/ws/rest/v1/module/?',
headers: { 'Content-Type': 'multipart/form-data;boundary=gc0p4Jq0M2Yt08jU534c0p'},
data: {file: file}
})
I am getting this following Error,
[Required MultipartFile parameter 'file' is not present]
Can someone help me to resolve this issues?
suthagar23
(Suthagar Kailayapathy)
June 1, 2017, 5:08pm
2
I solved this problem, @dkayiwa It’s working
The error message showed me like “Could not write JSON ”. That means It could not write the JSON type response to the request.
So I tried this manually and Identified, The response is based on application/xhtml+xml format.
Then after, I changed my header with " ‘Accept’: 'application/xhtml+xml;charset=UTF-8 ’ ".
Finally, It works without any problems .
Working Code for the POST request,
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined , 'Accept': 'application/xhtml+xml;charset=UTF-8'}
})
.success(function (data, status, headers, config) {
$scope.PostDataResponse = data;
})
.error(function (data, status, header, config) {
});