Skip to main content
added API method
Source Link
DoIt
  • 3.5k
  • 11
  • 58
  • 112

I trying to post to a api with accepts an integer parameter using angular as below

 function getDailyErrors() {
            var uri = "/api/users/error-counts/";
            var inData = { numberOfDays : 5}
            return $http.post(uri, inData)
                .then(function (response) {
                    return response.data;
                });
        }

API

 [HttpPost]
        [Route("api/users/error-counts/")]
        public MultiCategorySeriesDto<int> GetErrorCounts(int numberOfDays=15)
        {
            return _uow.Events.Errors(numberOfDays);
        }

for some reasons the API doesn't accept the parameter I passed instead takes the default int parameter. May I know where the mistake is?

I trying to post to a api with accepts an integer parameter using angular as below

 function getDailyErrors() {
            var uri = "/api/users/error-counts/";
            var inData = { numberOfDays : 5}
            return $http.post(uri, inData)
                .then(function (response) {
                    return response.data;
                });
        }

for some reasons the API doesn't accept the parameter I passed instead takes the default int parameter. May I know where the mistake is?

I trying to post to a api with accepts an integer parameter using angular as below

 function getDailyErrors() {
            var uri = "/api/users/error-counts/";
            var inData = { numberOfDays : 5}
            return $http.post(uri, inData)
                .then(function (response) {
                    return response.data;
                });
        }

API

 [HttpPost]
        [Route("api/users/error-counts/")]
        public MultiCategorySeriesDto<int> GetErrorCounts(int numberOfDays=15)
        {
            return _uow.Events.Errors(numberOfDays);
        }

for some reasons the API doesn't accept the parameter I passed instead takes the default int parameter. May I know where the mistake is?

Source Link
DoIt
  • 3.5k
  • 11
  • 58
  • 112

posting to an api with integer parameter not working with angularJs

I trying to post to a api with accepts an integer parameter using angular as below

 function getDailyErrors() {
            var uri = "/api/users/error-counts/";
            var inData = { numberOfDays : 5}
            return $http.post(uri, inData)
                .then(function (response) {
                    return response.data;
                });
        }

for some reasons the API doesn't accept the parameter I passed instead takes the default int parameter. May I know where the mistake is?