Questions tagged [asp.net-web-api]

The incredible ASP.NET Web API serves as a powerful framework to construct exceptional HTTP services specifically designed for various types of clients, such as web browsers and mobile devices. It leverages the mighty Microsoft .NET Framework, making it an optimal selection when aiming to develop RESTful services.

How to Send and Receive Data in One Request Using Android Studio and Web API

Currently, I am working on an Android App using Android Studio and the backend is being developed using Asp.Net Web API. Web Api Part [System.Web.Http.AcceptVerbs("GET", "POST")] [System.Web.Http.HttpGet] public dynamic GetTest(string name) { List< ...

The Web API's GET request results in an HTTP/1.1 500 Internal Server Error being returned

When creating controllers using Entity, I have encountered an issue with one particular model in my project. While the "Get method" works fine for all other models in the context, it seems to be causing a problem for this specific one. The code in questio ...

Creating a dynamic web application using Asp .NET Web Api, MVC, and Angular 2, integrating an action that

Working on an ASP .NET MVC application integrated with Angular 2, I encountered a problem when trying to communicate from the angular service to a WebApi Controller. The issue arises when attempting to access an action within the WebApi Controller that req ...

unable to send an array from an AngularJS service to a web API

There seems to be an issue with passing the value of brandSelection in the web API controller. Here is my Angular service's $http.get() method: var _getItemByCategoryId = function (categoryId, currentPageNum, brandSelection) { var deferred = $q.defe ...

The Web API encountered an error while trying to serialize the response body for the specified content type

Working on an ASP.NET MVC 5 Web Api project. The application already has multiple APIs in place. Recently, I added a custom JsonConverter to handle date conversions based on timezone. public class CustomInfoConverter : JsonConverter { public overrid ...

Developing a custom JsonMediaTypeFormatter for a Webapi platform

I'm currently working on developing a custom JSONMediaTypeFormatter to send some JSON parameters to a web API endpoint. The goal is to encrypt the data returned from the web API, which requires creating a customized media type formatter. Within my webapic ...

Building on the foundation of Web API 2.0: Using JavaScriptConverter for Tailored Date Formats

I want to standardize every DateTime object to follow the format "yyyy-MM-dd". Previously, I achieved this by adding the following code snippet to WebApiConfig.cs using JSON.Net: config.Formatters.JsonFormatter.SerializerSettings.Converters.Add( ...

Is it secure to utilize Http.Get (with parameters) for accessing WebApis in Angular 2/4?

When calling a Web API in Angular, is it safe to use Http Get with passwords included in the fields? Or would it be more secure to utilize Http Post instead? Check out this example on how to execute an Http.get request in Angular: http.get(baseUrl + &apo ...

Retrieving data with long parameters from a WebAPI GET request

Whenever I make a GET request to WebAPI using AJAX, I keep getting a 400 - Bad Request error. I have come to understand that this happens because the URL I am using is too long; the parameter I need to pass looks something like this: 1739;1591;2021;747 ...

Migrating image information from Angular version 14 to Asp.Net Core 6.0 Rest Api

When transferring product model data from Angular to a REST API using FormData, there is an images array included in the product data. Upon receiving this product in the REST API, the images data is accessed using Request.Form.Files. The images are then se ...

Calls to webApi with an Angular disorderly (asynchronous) pattern

Whenever I type in a textbox, it triggers a call to a webapi. The issue is that if I type too quickly, the calls and responses get mixed up. For example, when typing "hello": call with h call with "hel" call with "hello" call with "hell" call with "he" ...

Angular class mapping of web API response

I have a web API action method that returns a chapter ID and chapter name. I would like to convert this into an Angular class with an additional field called 'Edit', which by default is set to false. export class Chapter { chapterid: number; chapterna ...

Secure your Public .Net Core WebAPI with JSON Web Tokens (JWT)

Exploring the use of JWT to secure my .net Core WebAPI endpoints for a public API. The API is intended to be exclusively accessed by a React front end that operates without user authentication. The goal is to restrict access to the WebAPI endpoints solely ...

Utilizing a JSON object to send data to a C# WebAPI POST endpoint that accepts a parameter of a generic abstract class

I have a generic abstract class that defines the structure of an object to be POSTed to this endpoint. The class is as follows, with an example implementation: public abstract class Animal<T> { public string Name { get; set; } pu ...

The display within the object array in Angular is failing to show any values

Problem: The angular for loop is not displaying values on line {{ item.Id }}. Although the correct length of 10 is being retrieved, no actual values are shown in the screenshot below. https://i.stack.imgur.com/9keGn.png Debugging: Running console.log(thi ...

What is the reason behind the failure of my dynamically included jQuery handler at the back?

When a button is clicked, I am updating the HTML on a webpage along with the CSS and jQuery. The first time the jQuery (button click event handler) works correctly, but after that, it throws an exception. This static AJAX jQuery callback code includes the ...

Guidelines on configuring JsonSerializerOption on a request-specific basis

I have developed a .NET 7 web api with an endpoint that fetches user data. public class User { public Guid? Id { get; set; } public String? Name { get; set; } public Int32? Age { get; set; } public String? HairColor { get; set; } } When th ...

use ajax to post saved data to a WebAPI in php

I have successfully implemented the code to save data in a custom table using Ajax. Now, I need to figure out how to send this data to an asp.Net API using js/jQuery. How can I achieve this? Below is my HTML form and JS code: <div id="inline1" class= ...

"415 (Unsupported Media Type) encountered when making a POST request in a REST API

I've encountered an issue with a React component where a checkbox triggers a POST request to a REST API with a single parameter. Despite setting a breakpoint in the WebAPI code, it's not being hit and I'm receiving a 415 Unsupported Media Ty ...

Enhancing WebAPI service with batch request capabilities

My Batch WebAPI and WebAPI service have been registered in the webapiconfig.cs file with the following code: config.Routes.MapHttpBatchRoute( routeName: "WebApiBatch", routeTemplate: "api/$batch", batchHandl ...

What exactly does the Test Explorer initiate?

Currently, I am interested in performing tests on a web page front end that interacts with an ASP.NET RESTful Web API using Selenium. My understanding is that when I select "Run All" in the test explorer, it initiates my web server, opens my web page (re ...

Changing JSON format into a DataTable using C#

Currently, I am attempting to transform a JSON string into a DataTable within WEBAPI The structure of the JSON string is as follows: [ [ "Test123", "TestHub", "TestVersion", "TestMKT", "TestCAP", ... ...

Error 405 - Invalid request method

Here is my JQuery code for calling a web API: let request = { RequestId: "123", DeviceId: "ACU-B2-01-R1", AccessType: "Unlock", LoginId: "tester", Password: "tester" }; $.ajax({ url: 'http://localhost:55208/api/accesspanel&ap ...

Is it possible to have multiple POST requests for an ApiController?

The situation: Imagine a User class that consists of various groups of properties: password, address, preference, and roles. We require different Ajax requests to update (1) the user's password, (2) their profile, and (3) the roles they belong to. ...

transmitting data in JSON format through an HTTP URL

I have successfully implemented data transmission from my Android app to a REST Service using asp.net web api. The URLs I am sending, such as , are being processed in the web.api. Now, in the Android client, I am using GSON to convert a complex object in ...

Using a .NET Web-API controller variable as a parameter in a JavaScript function

I am looking to send a "variable" from the controller to a JavaScript function. The code I have implemented is as below: <div ng-controller="faqController"> <div ng-repeat="c in categories"> <h2 onclick="toggle_visibility(&apos ...

Issues with transferring object data from JavaScript to a Web API

I am facing issues while attempting to transfer a file from my local machine to SharePoint using JavaScript to ASP.NET MVC Web API call. I continuously encounter errors such as Type error, resource not found, etc. Is there anyone who can provide assistance ...

What is the process for obtaining JSON data on a C# WebAPI backend?

How can I successfully receive JSON data on my WebAPI backend in C#? I am facing an issue with the JSON data sent from my JavaScript frontend. { "User_Id": 1, "TotalPrice": 35, "DeliveryAddress": "At my house", "CartItems": [ ...

Encountering 'Error 405 - Method not Supported' while making an Ajax POST request in ASP.NET Web API

I am currently in the process of developing a straightforward Web API service that captures input data from an HTML form, converts it into JSON format, and forwards it to a Web API. My coding platform is ASP.NET Web API on Visual Studio 2017. To further el ...

The data retrieved from the web API is not undergoing the necessary conversion process

I am facing an issue with a web API call where the property checkNumber is defined as a double on the API side, but I need it to be treated as a string in my TypeScript model. Despite having the property defined as a string in my model, it is being receive ...

Creating SQL server tables from JSON automatically in C#

Users are sending me JSON Form Data. Here is an example of the data: { "Name":"Mike", "Age":25, "Gender":"Male", "Skills":{ ".Net":true, "Mule":"" } } I need to save this data in a table on SQL Server, but there isn't alrea ...

What is the best way to forward a file upload request from a Next.js API to another API?

Trying to crop an image within a Next.js application, then sending it through an API route within the app before reaching an external API endpoint is proving to be a challenge. The process works fine without going through the API route, but once that step ...

Navigating a FormData object in javascript on a .NET WebAPI version 5.2.2

I am currently working on integrating webcam video recording upload using the example provided in this RecordRTC GitHub repo. However, I have encountered a compiling error when trying to use "Request.Files" as indicated in the screenshot below. The error ...

Web API Implementation of Null-Safe Empty List Handling

I have a scenario where an angular controller is making a POST request to a web API method. I attempted to implement null safety with the IEnumerable, but it ended up causing the IEnumerable to always be empty. Here is the angular call: $http.post(custom ...

The server is unable to receive lists that are included within the JSON object being passed in

Below are the data contracts utilized in the function. public class ResumeSkillsListDataContract : IResumeSkillsListDataContract { public IList<ISkillDataContract> KnownSkillsList { get; set; } public IList<ISkillDataContract> BadSkill ...

Angular encountering a 405 Method not allowed error along with the "Provisional Headers are shown" message

It's really frustrating me. I'm attempting to make a simple request to my api server by adding the header, but it keeps showing me the message "Provisional Headers are shown" and then fails on the subsequent request. Provisional headers are sho ...

Is there a reason why I am unable to include a URL as a JSON element in the data attribute of an AJAX request?

I'm working on an ajax request where I pass data to the data property in this manner: var myData = { "ID": 123456, "Description": "Some description", "Name": "Product Name", "ImageUrl": "http://example.com/im ...

Circular reference occurs when two or more objects refer to each other in a loop

I am currently working with AngularJS, EF, and WebAPI. Within my project, there exists a one-to-many relationship between ObjectA and ObjectB. When it comes to the user interface, I need to iterate through a list of ObjectA and display it as follows: &l ...

Configuring IIS routing for seamless integration with Angular routing

After deploying my front-end Angular application on an IIS server and my back-end ASP.NET web API application on a separate server, I encountered an issue. Even though I can access the web page when visiting the Angular application's URL and navigate ...

Leveraging Spotify's webAPI to listen to a randomly selected album by a specific artist (ID

Welcome to my little project! As I am not a developer myself, please bear with me for any silly questions that may arise. My idea is to create an "audio book machine." The concept involves using a website that showcases various artists of audiobooks. Upo ...

Is it possible to send an array as a parameter to the Delete() action in a WebAPI using a jQuery Ajax call?

I have been working with WebAPI and successfully implemented a controller method called Delete, using the HTTP verb [HTTPDELETE]. Here is the syntax I used: [HttpDelete] public Resonse Delete([FromBody]Guid[] input) { // code for proc ...

What is the best way for my web application to interface with a serial port?

I am working on a cloud-based web application that uses ASP Web API and Angular, both hosted on Azure. I have a requirement for my Angular app to communicate with a serial port for reading and writing data. How can I achieve this functionality? I've come ...

An Angular application running on an Azure App Service experiences crashes exclusively when accessed through the Chrome browser

My webapi/angular site is hosted on the same Azure app service, with authentication token and other APIs located at /site/api and the angular app at /site/app. Everything works fine on our staging environment, which is a Windows 2012 VM with IIS 7. The an ...

Receiving an error message stating "The JSON value could not be converted to System.Int32" when attempting to post JSON data via AJAX to a Web API

I need to transfer information from my website to a WEB API that my partners are developing via AJAX. This WEB API is built on a .net Core 3.0 application, and the purpose is to register new users. However, I am encountering an issue with parsing the inpu ...

Encountering a StackOverflowException while using JsonConvert.DeserializeObject

Currently, I am working on a project that encompasses an ASP.NET Web API (running on .NET 4.6.2) as the backend, a Web API Client Implementation PCL serving as the middleware, and Xamarin.Forms projects as the frontend. Following recent modifications to my ...

I am having trouble making an HTTP GET call to my API using AngularJS

I'm currently working on a Web Application and have encountered an issue with making HTTP GET calls from Angular to my API. The strange thing is that I've tested my API in both the browser and Postman (using Chrome) and it works perfectly fine. T ...

Do the benefits outweigh the challenges of integrating AngularJS and KendoUI together?

Working with AngularJS has been a great experience for me recently, especially in creating custom abstract data factories. The features it offers are really impressive. KendoUI also provides similar features like MVVM and SPA routes that AngularJS offers. ...

How to update Angular Material table dynamically after CRUD operation without needing to reload the page

Hello, I am currently using Angular (v.9) along with ASP .NET Core Web API and EF Core (v 3.1) to perform CRUD operations. I have a region component form which is used as a dialog, you can view it https://i.stack.imgur.com/6w7hO.png The HTML code for the ...

The combination of Angular JS, Cross Domain, and Web API is a powerful

I'm looking to integrate Angular JS with Web API for my application. Technologies: Visual Studio 2013, .NET 4.0, Microsoft Server 2003. My Web API and Angular JS Client are on separate domains [Required]. I attempted to implement this using .NET 4.5 ...

Tips for managing the response from a POST request using jQuery

I'm currently working on sending data via POST to my ASP.Net MVC Web API controller and retrieving it in the response. Below is the script I have for the post: $('#recordUser').click(function () { $.ajax({ type: 'POST', url: 'api/RecordUser', ...

Navigating the JSON format with inherited classes: Best practices

I require my web-api to provide a JSON serialized list of Rule instances. [HttpGet] [SwaggerOperation(nameof(GetRules))] [SwaggerResponse(StatusCodes.Status200OK, typeof(List<Rule>), "Rules")] [ProducesResponseType(StatusCodes.Status200OK)] public a ...

Here is a guide on showcasing information obtained from ASP.NET API in Angular version 13

My goal is to fetch motorcycle data from a web API and showcase it in my Angular project. ASP.NET Framework Web API 4.7 Angular CLI: 13.3.7 Angular: 13.3.11 On the Web API end: Controller: [EnableCors(origins: "*", headers: "*", ...

Leveraging WebApi for ADFS authentication

We are currently working on setting up the following scenario: An HTML page sends an AJAX request to a WebApi inquiring about whether or not a user has a specific role. The WebApi then checks with ADFS to see if the user is logged in (if not, it authentic ...

What causes an error in returning an entity with a one-to-many relationship in a web API?

Hey guys, I have a One to Many relationship with the same class called User. In my web API's GET method, I am returning just one instance of the user and it seems to be working fine as long as there are no issues. User ID | Name 0 | A 1 | B ...

AngularJS http requests fail to include session cookies when making CORS requests

Here is the script I am using: <script> function eventController($scope, $http) { $http.get("http://example.com/api/Event", {withCredentials: true}) .success(function (response) { $scope.even ...

An ApiController parameter is receiving a null value for a complex type

For some reason, the parameter "ParametroFiltro Filtro" is returning null in my code, while the other parameters ("page" and "pageSize") are working correctly. public class ParametroFiltro { public string Codigo { get; set; } public string Descric ...

Serializing data in OData protocol

Struggling for the past 2 months to devise a unique solution for custom serializing an entity returned from an OData controller. Desperately seeking assistance! The scenario is fairly straightforward, and I have distilled it even further to pinpoint the i ...

Having difficulty sending a cross domain AJAX request (from localhost:50675 to localhost:27081) while using IIS Express with two distinct projects within a single solution

I have a situation in Visual Studio 2015 where my solution includes two projects: an ASP.NET MVC app and an ASP.NET Web API app. These two apps use different ports in IIS Express, causing some issues during debugging. While debugging, I noticed that the C ...

Tips on managing ASP .NET API's HttpResponseMessage for file downloads

I came across a solution on how to download a file from an asp.net API at this link: As a result, I created an API handler with the following code: public HttpResponseMessage Post([FromBody]dynamic result) { var localFilePath = graph ...

Populate an array using a web API AJAX request in jQuery

I'm encountering an issue with jQuery or Javascript. My goal is to display additional flags in Google maps from an IP array. I've successfully passed the IP array to the function, but when I use ajax to call the web API multiple times corresponding to the ...

A Step-by-Step Guide to Transferring Information from SAML Response to Angular App in Web API and Loading the

After successfully adding SAML support to the backend of our WebAPI following OKTA authentication, a new challenge has emerged. We now face the dilemma of establishing a connection with our AngularJS app when the browser itself serves as the triggering po ...

Ways to resolve the issue of an untraceable image associated with a json mime type

I recently came across this code snippet in my web.config <staticContent> <remove fileExtension=".svg"/> <remove fileExtension=".svgz"/> <remove fileExtension=".eot"/> <remove fileExtension=".otf"/> ...

What is the process for verifying and authenticating a token's header?

Trying to incorporate token in the search functionality. The token is used to check the header for identification, ensuring that the request passes through all steps. If incorrect, the request is cancelled and returned. Requested JSON { "header": { "To ...

Steps to automatically return JSON in a Visual Studio web API1. Open your Visual Studio

After setting up a Web API project in Visual Studio 2013, I noticed that when I visit a sample restful URL in my browser, such as http://localhost/values/5, it returns XML. Is there a way to configure it so that it defaults to returning JSON instead of X ...

The web API PUT method is able to process query strings, however it is not properly

When I use users as a query string parameter and set the web API method to look for them in the URI, everything works fine. However, when I pass them in as shown below, the users variable ends up being null. What could be causing this issue? Angular funct ...

Unable to show the data returned from service in Angular 2 component

I am facing an issue with my Angular 2 component that calls a service to retrieve data, but the data is not displaying on the HTML page. It seems that the roots array is coming back as a nested array. I have double-checked both the data and the HTML struct ...

The jQuery ajax request functions properly on Internet Explorer but does issues arise when used on Firefox, Chrome, or Opera browsers

I have created a test web page to call a WebApi URL and receive a response. The functionality works perfectly in Internet Explorer, but fails in all other browsers. Below is the jQuery code snippet I am using: $(document).ready(function() { jQuery("# ...

Exploring the integration of Ping Federate with Angular and Web API through Windows Identity Foundation (

I am currently implementing Ping for user authentication in an Angular/.NET Web API environment with WIF. Typically, configuring WIF in the web.config file of an MVC or web Forms application allows for seamless integration, as it automatically intercepts p ...

Steps for packaging an AngularJS and WebAPI 2 web application as a Cordova bundle

I am currently working on a portal using VS.Net 2013, Asp.Net WebAPI-2, and AngularJS 1.4. I want to convert this portal into a Cordova package in order to improve the application start time. While my portal is responsive and fits well on mobile devices, s ...

Instructions on transferring information from the app.component to its child components

I am currently working with Angular 6 and I have a specific requirement. I need to send data retrieved from an external API in my app.component to other child components. Instead of repeatedly calling the common API/service in every component, I want to ma ...

Retrieve data from an ASP.NET Web API endpoint utilizing AngularJS for seamless file extraction

In my project using Angular JS, I have an anchor tag (<a>) that triggers an HTTP request to a WebAPI method. This method returns a file. Now, my goal is to ensure that the file is downloaded to the user's device once the request is successful. How c ...

Exploring the world of JSON communication through MVC Web API: A comprehensive guide

Similar cases to mine have been answered before, but my specific needs always seem to differ from others' problems. I am facing an issue where I'm sending JSON data from my HTML page to the MVC Web API, but unfortunately, the data I receive is always null ...

The Angular 2 http request seems to be failing to reach the web api's get method when using a string parameter overload

Issue at hand is that the initial Get method gets triggered by this particular HTTP request: http://localhost:56690/api/testelements/?name=aeg One would anticipate the second (string overload) method to be invoked due to the presence of a string parameter ...

Tips for renaming property names during JSON serialization in asp.Net

In my MVC Web API Controller, there is a method that I have exposed: [HttpPost] public JsonResult<CustomClass> Details(RequestClass request) { var encoding = Encoding.GetEncoding("iso-8859-1"); var settings = new ...

Received an error while attempting an AJAX GET request to a distinct server hosting a WebAPI

This is my first time encountering an issue with an Ajax request in client-side code. I'm hoping that there's a simple mistake in my code that I'm just overlooking. Just to give some background, when I manually access the URL mentioned below, I receive a J ...