question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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 issue

I 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:closed
  • Created 8 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
gameboxcommented, Nov 20, 2015

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

5reactions
torbenrcommented, Apr 10, 2018

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”

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found