"Troubleshooting the issue with AngularJS not posting correctly to MVC

Can you help me troubleshoot why I am getting a 500 error in MVC when attempting to post to my controller from AngularJS? There are no exceptions being thrown.

Below is the AngularJS code I am using:

var recordingRequest = {
    deviceSerial: 2160563840, 
    plannedStartTime: "2015-08-07T14:29", 
    recordingDuration: 60, 
    recordingDurationIsMinutes: true
}

The service responsible for posting the data is shown below:

deviceAPI.addDeviceRecording = function (recordingRequest) {
    // Request data
    return $http.post("/devices/adddevicerecording/", recordingRequest);
}

Lastly, here is the entry point of the MVC controller:

[HttpPost]
public ActionResult AddDeviceRecording(int deviceSerial, string plannedStartTime, int recordingDuration, bool recordingDurationIsMinutes)
{
}

I have tried setting breakpoints inside the AddDeviceRecording function but they are never reached. However, I can confirm it is partially working as it returns a 500 error instead of a 404. If I change the $http.post to an incorrect URL, a 404 error is returned instead.

Answer №1

The serial number of your device has exceeded the allowable limit.

In C#, the maximum value for Int32 is 2,147,483,647, while your device's serial number is 2,160,563,840.

You must update your data types accordingly.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Cut off the initial characters in the URL's hash component

Hey there, I'm currently working on a task that involves removing a specific part of a URL string. Here's the scenario: if (window.location.hash == '#super-super-product') { change.window.location.hash.to.this: #product // this i ...

Automate the process of making Tailwind Classes non-Global with ease!

I am currently working on an application that consists of two main parts: (X) an older AngularJs legacy application with its own set of CSS classes. (Y) a new React application contained within a div. This new part (Y) is built using webpack, postcss, and ...

Protractor - Error: prop is undefined

Need assistance in identifying an error. Currently, I am learning Protractor and attempting to create a basic test using Page Object. //login_pageObject.js let loginContainer = function() { this.usernameInput = $("input.login-form-01"); this.passwordInp ...

Protractor and Azure AD authentication test in action

I am having trouble authenticating a user with an end-to-end test. Despite clicking the button on the Azure AD login page, the test does not proceed as expected. describe('angularjs homepage', function() { var ptor = protractor.getInstance(); p ...

Utilize AJAX request to populate a datatable with JSON data and incorporate hyperlinks for seamless

Below is the datatable java script I am using: $('#Proj_emp_table').dataTable({ "sAjaxSource": "/projects/project_json/", "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { ...

Having trouble with v-model not updating the data value on a dropdown in Vue.js?

When I set the initial value on the data property, the dropdown option is correctly displayed. However, if I select a different value from the dropdown, the data property does not update accordingly. <select class="form-control" ...

How about creating a customized sorting algorithm from the ground up that incorporates a comparator?

My current assignment requires me to create a unique sorting method from scratch (cannot use Array.sort()) that accepts a comparator and organizes a list based on that comparator. const people = [ {name: 'Bill', age: 30, likes: 'food' ...

`How to Create a Custom URL in Umbraco CMS to Redirect to an Existing Website`

We currently have a dynamic, multi-lingual app running on Azure built with AngularJS. In order to manage some of the publicly accessible pages more efficiently, we are considering hosting another application with a content management system (CMS). Our prop ...

Is there a way to navigate to the next or previous image in a lightbox by using ev.target.nextElementSibling or ev.target.prevElementSibling?

I am new to the world of web development Currently, I'm facing an issue with my lightbox feature. I want to navigate between images by using ev.target.nextElementSibling and ev.target.prevElementSibling when clicking on the next/previous arrow.png ic ...

What is the reason behind ASP MVC model binder's preference for JSON in POST requests?

Is there a way to bind data to a model when sending a 'GET' request with JSON.stringify() using AJAX? Currently, the model value is always null when using 'GET', but it works fine with 'POST'. Are there any solutions for this ...

The function Router.push("/") is not functioning as expected when called within the pages/index.js file

Currently, I'm utilizing the Next JS next-auth/react library and aiming to direct authenticated users straight to the dashboard. Here's a snippet from my index.js file: import { useRouter } from "next/router"; import Link from "nex ...

Fiddle demonstrates HTML functionality, while local testing is unsuccessful

Currently, I am in the process of creating an image slider and attempting to run it on my personal computer. However, upon doing so, I have encountered a problem where the page is not rendering correctly. Additionally, I receive an ActiveX warning message ...

JavaScript - Not a Number

I am currently facing an issue while attempting to calculate the Markup of a product. I keep receiving a 'NaN' error in my console, which I understand stands for Not a Number. However, I am struggling to identify and rectify the root cause of thi ...

Angular directive for concealing the 'ancestor' of an element

I have created a code snippet that effectively hides the 'grandparent' element of any '404' images on my webpage. Here is the code: function hideGrandparent(image){ image.parentNode.parentNode.style.display = 'none'; } < ...

Prevent incorrect data input by users - Enhancing JavaScript IP address validation

I have been trying to create a masked input field for entering IP addresses, but every solution I come across seems to have some flaws. The best solution I found so far is , but it still allows values higher than 255 to be entered. It works fine initially ...

Combining two objects by aligning their keys in JavaScript

I have two simple objects that look like this. var obj1 = { "data": { "Category": "OUTFLOWS", "Opening": 3213.11, "Mar16": 3213.12, "Apr16": 3148.13, "May16": 3148.14, "Jun16" ...

MongoDB was successfully updated, however the changes are not being displayed on the redirected

I have implemented the delete action in Node/Express as a web framework, where it is structured within a higher-level route: .delete((req, res) => { db.collection('collection-name').findOneAndDelete({ topic_title: req.body.topic_title}, ...

Incorporate the AngularJS controller into your JavaScript code

I am facing an issue with my jQuery UI dialog that contains a dynamic <select> populated with Angular and AJAX. The problem is that the AngularJS script still runs even when the dialog is not visible. To solve this, I added a condition to stop the s ...

Leveraging the UrlFetchApp class in Google Apps Script for interacting with dynamic pages powered by AngularJS

Trying to extract data from a webpage that uses AngularJS using Google Apps Script UrlFetchApp. The content on the page appears as placeholders like {{Field1}}, {{Field2}}, etc. These placeholders are then replaced with actual values after running angular ...

Executing a javascript function from an ajax-loaded webpage

I have a form where I upload a file using an ajax call that includes an API request. Once the API call is successful, I need to update a table displaying the list of uploaded files. Initially, I attempted calling a JavaScript function within the ajax page, ...