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.

Sharing information with connections through a REST API

Currently in the process of developing an API where I need to create a Post. The specific structure for this Post is as follows: { "Title": "Blog first post", "Body": "Some body text for the post", "PublishedAt": "2016-02-08", "Category": { "I ...

I am struggling to grasp the concept of integrating JSON.NET with ASP.NET Core WebAPI

After completing my first ASP.NET Core Web API project, I am interested in exploring manual JSON serialization/deserialization using the JSON.NET library. The JSON.NET documentation provides a simple example of manual serialization which involves creating ...

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

What is the process for integrating a MongoDB Bson formatter into Web API 2?

In my Web API 2 project, the WebApiConfig configuration is set up like this: public static class WebApiConfig { public static void Register(HttpConfiguration config) { config .MapHttpAttributeRoutes(); config ...

When using WebAPI, be aware that posting HTML entities may result in parameters

When sending the data of a div to the server using jQuery's AJAX method, everything seems to work fine. However, I noticed that when my content includes HTML entities like  , it gets truncated in my Web API controller. Raw POST From Fiddler ...

User account management in AngularJS web services

My latest project involves developing a web application on Azure. The backend is powered by a web API service while the frontend is supported by AngularJS, both hosted on Azure. I am now looking to implement a login page with individual user accounts, but ...

Updating Azure Table Storage Record through RESTful Web API调用

Currently, I am in the process of testing Azure Table Storage's REST API services. While I can successfully retrieve data from the table, I am encountering difficulties when attempting to update records using JavaScript. Interestingly, performing the ...

Retrieve JSON data in camelCase format from a Web API

My goal is to retrieve camel cased JSON data from an ASP.Net Web API 2 controller. To achieve this, I set up a new web application specifically with the ASP.Net MVC and Web API components. I modified the ValuesController as shown below: public class Value ...

Making asynchronous requests to a web API endpoint using Ajax

I'm currently working with the following view structure : <div id="addDisplay" class="display"> <div class="box-header"> <h3 class="box-title">Ajouter un compte</h3> </di ...

Creating API methods for a Node.js Express 3 application using Visual Studio 2015

Looking for guidance on writing API methods in a node.js express 3 application. My current app.js setup is as follows: const express = require('express'); const routes = require('./routes'); const user = require('./routes/user&apo ...

Extract a targeted array from a WebResponse request and convert it into a new array

I am trying to retrieve data from an external API that provides responses structured like this: { "meta": { "year": "...", "month": "...", "reasons": "...", "api_data": "..." }, "results": [ { "name": "David", "age": ...

Retrieve an Excel file through a web API with the help of AngularJS

Client-side Code var url = baseUrl+ "/api/Home/DownloadReport"; window.open(url); Server-side Code [HttpGet] public HttpResponseMessage DownloadReport() { var stream = new System.IO.MemoryStream(File.ReadAllBytes(@"C:\Users\my ...

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 $post not functioning while $ajax works successfully on the asp.net web api controller?

I'm curious about why the $.ajax() request is successful, but the $.post() method only returns an empty array on the controller. Here's the controller code snippet: [Route("api/actuary/{actuaryId:long}/documents/")] [HttpPost] public async Task ...

The formatting of dates and times may differ between Internet Explorer 10 and Chrome web

When using a web API controller and returning a date object without formatting, the data collection may appear as shown below: public IEnumerable<Event> GetData() { return new NORTHWNDEntities().Events.ToList(); } On the client side ...

Efficient responses for UPDATE and DELETE requests with WebAPI and Angular services: best practices

While working on my REST service, I have encountered the update and delete functionalities. In reference to a source, it is mentioned that the UPDATE operation should return a boolean response and the DELETE operation should respond with an empty reply. ...

Is there a way to verify that my transition from angular 2 to angular 4 in my app was successful?

Previously, my .NET WebAPI application utilized angular 2, but I made the decision to transition to angular 4. To upgrade, I executed the following commands in the cmd within my project directory (in addition to addressing any missing dependencies): npm ...

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" ...

Incorporating object data and a value into an Angular $http.post request and retrieving them in an ASP .NET Web API

I am seeking a way to send multiple objects and a value from an Angular application to an ASP .NET Web API. Below is the snippet of my JavaScript code: var productStockArray = $scope.ProductStockArray; var challan = 20; $http.post(dataUrl + "StockProduc ...

Issue with uploading files due to cross-domain restrictions in AngularJS and Web API

Having trouble uploading a CSV file from Angular using POST to a Web API endpoint, resulting in the following error: "XMLHttpRequest cannot load http://localhost:89/WebService/Upload. No 'Access-Control-Allow-Origin' header is present on the ...

Extract data from a JSON object sent from an Angular frontend and process it in a C# ASP.Net

Having trouble creating a new Salesman with Angular and C#. I am collecting user input data in an array (newData) from my Angular controller and sending it to my C# server-side controller through a service. However, I am encountering errors and unable to r ...

The interaction between Web API, Angular, and the unique MAC Address

My organization currently operates an Application using ASP MVC. However, the application is experiencing slow performance and confusion due to multiple programmers with conflicting ideas. I have taken on the task of refactoring and migrating it to Angular ...

The Web Api 2 is unable to process the grant type specified

I am new to working with Web Api and I am currently trying to implement authorization and authentication. However, I have encountered an error that is given below: When attempting to retrieve a token from the Web Api, I am receiving this error: {"readySt ...

Tips for aligning the types of objects transmitted from a Web API backend to a React/Redux frontend

After creating a backend for my app using .net, I now have CRUD operations available to me. When performing a POST action, the response includes an entire new item object: {"Id":"7575c661-a40b-4161-b535-bd332edccc71","Text":"as","CreatedAt":"2018-09-13T15 ...

Having trouble understanding why the jQuery script is not communicating effectively with the ASP.NET web API

Whenever I attempt to execute this script, a 500 error pops up. My setup consists of a demo project in asp.net mvc4 with a petite web api controller and the default home controller. Below is my API controller: namespace MyTrainingApi.Controllers { public ...

Using nodeJS to authenticate with Active Directory

Currently, my company is focusing on developing an AngularJS web app that interacts with a C#.Net REST API to retrieve all necessary data. The application users are required to log into Windows computers that are connected to an Active Directory, allowing ...

How to handle blank property values in JavaScript objects and convert them to null in an ASP.NET Web API

Hey there! I'm facing an issue where when I post a JavaScript object to an ASP.NET Web API, some property values are blank like the example below: var o={ ID=1, Fname="Tom", Mname="", Lname="Wilson" } However, in the Web ...

Receiving a 404 error after refreshing the browser in Angularjs routing

I am currently working on a project that involves Angular JS and asp.net web api. Whenever I navigate using this URL http://localhost:3458/Profile An error pops up saying: Description: HTTP 404. The resource you are looking for... However, if I use th ...

What other configurations are necessary to switch the default port of Angular from 4200 to a different number?

Currently, I am diving into the world of asp.net core webapi and angular 13 through Visual Studio Community 2022. The project setup involves two distinct projects built from these templates: Standalone TypeScript Angular Project Asp.Net Core Web API In ...

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

There seems to be an issue with retrieving data using an Ajax get request in Node.js and Express

I am currently working with an API in JavaScript: router.route('/books') .get(function(req,res){ Repository.getAll().done( function(result){ res.json(result);},function(err){res.send(err);}); }) .post(function(req,res){ ...

The asynchronous module has finished even though there is another operation still pending

Currently, I am working on connecting to the Quickbooks API and downloading employee information to save it in my local database. To achieve this task, I am utilizing AngularJS and WebAPI. However, I have encountered an error when attempting to save the in ...

Getting a 415 error when using InvokeApiAsync with StringContent in Monodroid/Xamarin.Android

Utilizing Xamarin Studio to create a Xamarin.Android application with Azure Mobile Service and .NET Backend custom managed API (WebApi 2). I have confirmed that my Mobile Service is functioning properly as I can see my app interacting with it in the logs. ...

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

Enhanced security through dual authentication for MVC and WebAPI

I have developed two separate applications: MVC and WebAPI. In my MVC application, I make ajax requests to the WebAPI on certain pages. Additionally, I am using IdentityServer3 for authentication and authorization. Currently, I have implemented cookie-bas ...

I thought enabling CORS would solve the issue, but it seems like the restrictions

This is my setup for an asp.net core web API: public void ConfigureServices(IServiceCollection services) { services.AddCors(o => o.AddPolicy("CorsPolicy", builder => { builder ...

Unable to render ASP.NET Core 2 WebAPI and Angular application on the webpage

Following a tutorial, I created an ASP.NET Core 2 Web API. The API functions properly when accessed through the browser at: https://localhost;44313/api/liveconsole To design the Angular UI for my web API, I referred to another tutorial. After multiple at ...

When accessing ASP.NET Web API at localhost:xxxx/api/product, the default page is displayed instead of returning JSON or XML data

I'm currently attempting to retrieve data from my SQLEXPRESS database via API for my UWP client app. Below is the code I have implemented: API controller: [Route("api/product")] public class ProductController : ApiController { // GET: api/prod ...

Controller return 400 error after Ajax request

My Ajax call is pointing to a controller function: <script type="text/javascript"> $(document).ready(function () { $('#AddNote').click(function () { $('#AddNote').addClass("disabled"); ...

The output from the Web API Controller model is empty

I am encountering an issue where the Web API controller with FROMBody always returns a null model. The model for a Product object includes ProductID and a List of Order objects: public class ProductModel { [Required] public string productID { get ...

What is the functionality of a Bearer token in token-based authentication within the framework of Asp.net MVC 5?

I recently implemented token based authentication in my project, following a similar method outlined in this website link. So far, the authentication has been successful for me. However, I do have two concerns: After adding the specified code, th ...

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 correspondi ...

How can we create a schema using JSON-Schema and then implement it using Mongoose?

Hey there, I'm currently dealing with an issue involving Mongoose. Is it possible to incorporate JSON-Schema into Mongoose Schemas? For instance, if I want to establish my API data schema using JSON-Schema, because it's convenient. It appears th ...

Sending image bytes through a query string can be achieved by encoding the image data

As a beginner in developing Rest services using web API in ASP.NET, I attempted to send an image byte within the query string but encountered difficulties. Unfortunately, I was unable to successfully send the image byte within the query string. While I ha ...

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

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

Deploying a WebAPI to the api directory of an Angular app hosted on IIS results in 500 errors when making requests

I have been working on developing an angular application with a WebAPI 2 backend. The two components are in separate repositories, directories, and environments - the angular project is not part of a Visual Studio project and I am using WebStorm to work on ...

Get your hands on the PDF file with Angular!

Having an issue with downloading a PDF from a WebApi using Angular. The downloaded file is only 15 bytes, even though the data being received from the WebApi appears to be of the correct size when logged as an arraybuffer. The WebApi [HttpGet] pu ...

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

Should the JSON data in an ASP.NET React application be serialized and normalized on the client-side or server-side?

Currently, I am in the process of developing a asp.net react application. Up until now, I have successfully completed the serialization and normalization of nested data on the client-side using normalizr. However, I am considering whether it would be more ...

AngularJS failing to trigger Web API Route configuration with multiple parameters

Hello, I am facing an issue with my WebApiConfig, API Controller, and Angular Service. The 1st route is working perfectly fine, but the 2nd and 3rd routes are not being called by AngularJS even though the web API route seems to be correct. --WebApiConfig ...

Saving any type of file in SQL Server with a field type of varbinary(max) can be achieved by utilizing Angular with ASP.NET Core to create a REST API

I am currently facing an issue while attempting to save a file, such as an image, in the Microsoft SQL Server Management Studio through asp .NET core for the Rest API. I have managed to create a base64 representation of the file, but I am unsure about the ...

Unable to perform a POST request to a web API endpoint

Here is the code snippet for saving records using my web API: var c = $.ajax({ url: 'api/values/CreateAjaxNew', type: 'POST', dataType: 'json', contentType: 'application/json; charset=utf-8', dat ...

During the selenium testing process, there is an issue preventing clients from connecting to the server

I am currently developing selenium tests (coded in C# using the chrome webdriver) for a javascript web application that utilizes a backend server powered by WebApi 5.2.4. The CORS feature is enabled with lenient settings: namespace SealingService { pu ...

Developing a GET endpoint that accepts multiple parameters and provides a list of dates as the output

I am in the process of developing a Web API where clients will need to send a GET request to receive a JSON list of dates. To get this result, the client must specify certain parameters: startDate (datetime) endDate (datetime) offset (int) type (str ...

Dealing with 400 Bad Request Error Handling in Angular 6 when communicating with WebApi (using HttpClient)

Here is an Asp.net Core WebAPI that handles bad requests by providing error details when a duplicate user attempts to register. public async Task<IActionResult> Register([FromBody] RegisterModel registerModel) { if (ModelState.IsValid) ...

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

Combining ServiceStack with MVC and AngularJs for optimal integration

Setting up web.API with MVC is a breeze - just keep the WebApiConfig.cs as default, create a new web.API controller, and then in your javascript make calls using $http.get("api/..."). I'm interested in achieving the same functionality using service s ...

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"/> ...

modify web API response type

I am currently developing a web API project and I need to customize the JSON type being returned. My aim is to return two arrays with a specific format as outlined below: Snippet from my controller public IHttpActionResult GetNOX(){ ------- ...

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

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

Initiating a single AJAX call, yet processing multiple requests on the server side

Currently, I am facing an issue with sending ajax HTML DELETE requests from my website to a RESTful Web Service (Asp.NET MVC 4 Web-Api ApiController). The goal is to delete selected data from an HTML table by using jQuery to get the selected row. Upon cli ...

Did an ASP.NET Core WebAPI HttpPost contain a JSON property?

Within my ASP.NET Core WebAPI Controller, I have a HttpPost method that receives the request body using the [FromBody] attribute. In this scenario, let's consider that I anticipate receiving the following JSON input, where null is an acceptable value ...

Error 405: Javascript page redirection leads to Method Not Allowed issue

After receiving the result from the ajax success method, I am facing an issue where the redirection to another page is being blocked and displaying the following error: Page 405 Method Not Allowed I am seeking suggestions on how to fix this as I need to ...

Could anyone provide a detailed explanation of how model binding functions in ASP.NET?

Hey there, I've been working on sending a post request from Reactjs to an ASP.NET API using axios. Initially, I encountered a 400 Bad request error. However, after making some changes to the DTO in the backend, the request went through. But now, the d ...

Ajax data is limited to GET requests

I'm currently utilizing Ajax in JavaScript to send a request to my Asp.Net Web Api with the following code: $.ajax({ type: 'POST', url: "/Api/User/Test", data: { "Id": "1", "FirstName": "John", "LastName" ...

Pass a Json object as a parameter to a Web Api controller in a .NET Core application

This code snippet utilizes Google API with Javascript var output = new Object(); output.PlaceID = place.place_id; output.Longitude = place.geometry.location.lng(); output.Latitude = place.geometry.location.lat(); $.ajax({ headers: { 'Acc ...

Managing CORS in Angular2 for REST WebApi calls

Currently, I am utilizing an Angular 2 front end along with a WebApi backend where the WebApi is CORS enabled. var cors = new EnableCorsAttribute("*", "*", "*"); GlobalConfiguration.Configuration.EnableCors(cors); This setup works well with different sit ...

Best practice for redirection after a $http.post request in angularjs

I need assistance with determining the best method for redirecting to a different page when $http.post returns a specific error code. For context, I am looking to redirect users to another page if they are not logged in or authorized to access the API. ...

Having trouble sending a JSON object from Typescript to a Web API endpoint via POST request

When attempting to pass a JSON Object from a TypeScript POST call to a Web API method, I have encountered an issue. Fiddler indicates that the object has been successfully converted into JSON with the Content-Type set as 'application/JSON'. Howev ...

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

Dynamically adjust checkboxes in AngularJSAngularJS enables dynamic

Just jumping into the world of AngularJS and seeking assistance on checkbox lists with WebApi integration. I have successfully implemented a checkbox list where users can select multiple options, and the selections are saved in the database. However, I am ...

There seems to be an issue with Jquery Ajax retrieving information from an ASP.NET WEB API

Recently, I have started delving into APS.NET MVC WEB API programming. My current dilemma involves creating an ASP.NET WEB API project with the following code: public class ValuesController : ApiController { // GET api/values public IEnumerable& ...

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