500 (Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value at [Source: java.io.StringReader@45a1bf65; line: 1, column: 3])
See original GitHub issueI am trying to upload an excel file with ng-file-upload. When I use the uploadBySubmit method, I get the following error.
com.google.appengine.repackaged.org.codehaus.jackson.JsonParseException: Unexpected character (‘-’ (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value at [Source: java.io.StringReader@45a1bf65; line: 1, column: 3]
I will be grateful if someone could let me know what I am doing wrong.
This is my controller:
angular_app.controller(‘settingsImportOrExportController’, [‘$scope’, ‘settingsImportOrExport’, ‘Utils’, ‘Upload’, function($scope, settingsImportOrExport, Utils, Upload){
$scope.uploadUsingUpload = function (file) {
file.upload = Upload.upload({
url: '/_ah/api/havasay/v1/resource/categories',
method: 'POST',
headers: {
'x-hs-salt': _salt,
'skey': (Utils && Utils.getOrganizationDetails() && Utils.getOrganizationDetails().skey),
'Content-Type': undefined
},
fields: {organizationId: Utils.getOrganizationDetails()._id},
file: file,
fileFormDataName: 'myFile'
});
file.upload.then(function (response) {
$timeout(function () {
file.result = response.data;
});
}, function (response) {
if (response.status > 0)
$scope.errorMsg = response.status + ': ' + response.data;
});
file.upload.progress(function (evt) {
// Math.min is to fix IE which reports 200% sometimes
file.progress = Math.min(100, parseInt(100.0 * evt.loaded / evt.total));
});
file.upload.xhr(function (xhr) {
// xhr.upload.addEventListener('abort', function(){console.log('abort complete')}, false);
});
};
}]);
This is my html file:
form name=“myForm” ng-controller=“settingsImportOrExportController”
<fieldset> <legend>Upload on form submit</legend> Profile Picture:<button ng-disabled="!myForm.$valid" ng-click="uploadUsingUpload(picFile)">Submit</button>
<!-- <img ng-show="picFile != null" ngf-src="picFile" class="thumb">
<span class="progress" ng-show="picFile.progress >= 0">
<div style="width:{{picFile.progress}}%" ng-bind="picFile.progress + '%'"></div>
</span>
<span ng-show="picFile.result">Upload Successful</span> -->
</fieldset>
/form
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
expected digit (0-9) to follow minus sign, for valid numeric ...
System.JSONException: Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid ...
Read more >Unexpected character ('-' (code 45)) in numeric value
On execution I'm getting the 400 status code and following error ... (code 45)) in numeric value: expected digit (0-9) to follow minus...
Read more >Solved: Import Health Rule error message - Unexpected char...
{ "statusCode" : 400, "message" : "Unexpected character (- (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid...
Read more >(code 45)): Expected space separating root-level values at ...
Using swagger vertx codegen, i have generated some verticle files. In one example, i try to allow the user to pass me a...
Read more >Getting error in generating token through REST API - OpenVidu
JSON parse error: Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Don’t really understand why this issue is closed. No resolution seemed to be reached. I was actually experiencing the same bug with almost identical code. For me, all that had to change was putting the widget inside of a named form. Might not address the issue above, but that may help someone else witht this issue
Hi - I had a very similar problem trying to send a request via PostMan to the Nuxeo API. To cut a long story short I was mistakenly setting “content-type” as “application/json” when it should have been “multipart/form-data”