Click here to Skip to main content
15,892,480 members
Everything / WebAPI

WebAPI

WebAPI

Great Reads

by kusnaditjung
Web specification and framework
by Fred Song (Melbourne)
Build a simple finance application with Angular 13 and .NET 6
by John Atten
When working with ASP.NET Web Api from a .NET client, one of the more confounding things can be handling the case where errors are returned from the Api. Specifically, unwrapping the various types of errors which may be returned from a specific API action method, and translating the error content in
by Vincent Maverick Durano
This article will talk about how to implement a custom wrapper for your ASP.NET Core and Web API applications for managing exceptions, providing meaningful and consistent responses to consumers.

Latest Articles

by Zijian
Use the codes generated by OpenApiClientGen in real world applications
by Zijian
Construct Angular Reactive Forms of client data models through generated Angular TypeScript codes
by Zijian
Construct Angular Reactive Forms of client data models through generated codes
by Zijian
A series of articles comparing programmer experiences of Angular, Aurelia, React, Vue, Xamarin and MAUI

All Articles

Sort by Updated

WebAPI 

10 Apr 2024 by Graeme_Grant
Quote: When Manager clicks either of the link, it hits the endpoint and their response is Captured in Database. To prevent sharing, the only option is for the intended recipient to log back in, then you verify both the account used to sign in...
10 Apr 2024 by Pete O'Hanlon
I'm afraid you need to go back to whoever gave you the requirements and explain this is a monumentally bad idea, and also impossible to implement. If one manager forwards it to another, you can't prevent that, and you can't change the contents of...
10 Apr 2024 by Vaithilingam Alagappan
When User raise a request for Access. User's Manager needs to approve the request through email. The email will have Approve and Reject link as API endpoint URL. i.e., Approve - https://example.com/api/approve, Reject -...
23 Feb 2024 by MaMon2010
Hi, I have an asp.net core 8 webassembly solution with two clients and an API server, one of the clients (noAuthJWT) is public and must have no authentication for users, the other is back-office and protected with JWT authentication. Wanting to...
1 Feb 2024 by Zijian
Use the codes generated by OpenApiClientGen in real world applications
10 Jan 2024 by Zijian
Construct Angular Reactive Forms of client data models through generated Angular TypeScript codes
9 Jan 2024 by Zijian
Construct Angular Reactive Forms of client data models through generated codes
8 Dec 2023 by Zijian
A series of articles comparing programmer experiences of Angular, Aurelia, React, Vue, Xamarin and MAUI
27 Nov 2023 by Graeme_Grant
A few things: 1. You're asking for paging however paging is not part of the EF query. 2. An EF GET should use NoTracking unless you are going to update and postback to the db. In your case, you're running a pagination query and forget with...
26 Nov 2023 by Gruja82
Hello, everyone. I'm facing pretty strange behavior in my Blazor hosted app. Controller correctly receives parameters from client service and then invokes method in my repository for retreiving data. But problem is when invokes method in...
25 Oct 2023 by ramesh P Oct2023
I had developed the blazorWASM Hosted Application with IndexedDb. This application has two projects, client and server projects. Client project purely runs on browser and server project contains ASP.NET Core API and ASP.NET Core Server hosted...
24 Oct 2023 by ahmed_sa
I work on ASP.NET MVC Project. I face issue action ApprovalIndex Not redirect to action PendingManagersRequests although no error happens. I debug and trace breakpoint until I reach action PendingManagersRequests and trace until I reach to view...
16 Oct 2023 by Graeme_Grant
.Net (Core)Hosted Services run in a different container to normal Dependency Injection, therefore, to access, you need to access them differently. You can read about it here: Background tasks with hosted services in ASP.NET Core | Microsoft...
12 Sep 2023 by s yu
Is it possible to execute .bat through a WebAPI call? I created a Windows Service. Then I created several .bat files to install, uninstall, start, or stop the service. Now I want to use a WebAPI call to run a .bat file. What I have tried: ...
11 Sep 2023 by OriginalGriff
Probably not: Your API code will be running on your server, not on your client - so any .BAT file will also execute on the server, not the client. And regardless of what the file does, the server has no way to access executables on the client...
25 Jul 2023 by Member 13304618
I have a design question; thus, no code samples I am trying to create a Web API Core project that would use an EF Core to communicate with a database. I read about the Data Access design pattern and realize that I have to place a Web API project...
25 Jul 2023 by Richard Deeming
Quote: the EF core cannot reference the Web API You've just answered your own question: the mapping needs to be done in a project which has references to both the entity classes and the DTOs you're mapping to. Personally, I'd be inclined to...
4 Jul 2023 by Akaash Kumar
As in Postman we have certificate and key file, how do I validate the KEY file using c# or MVC. I have tried adding the below code but seems like for the KEY file we've some other code to write. Please suggest some help. What I have tried: ...
4 Jul 2023 by Richard Deeming
Quote: string base64cert = Convert.ToBase64String(File.ReadAllBytes(pemFilePath)); var cert = new X509Certificate2(Convert.FromBase64String(base64cert), certAuthCode); First obvious problem: converting the byte array read from the file to a...
28 Jun 2023 by Jithu_007
I am new to .NET Core web API development and have recently started working on a project at my company. I cloned a .NET Core 6.0 web API project from GitHub and I am trying to run it locally. However, when I test it using Postman, the breakpoints...
28 Jun 2023 by Dave Kreskowiak
with postman getting 504 gateway error Your breakpoints are never getting hit because the request is never getting to the controller. You have to solve the 504 error first before you can start debugging the code in the controller. This can come...
4 May 2023 by JayWalks
A walkthrough of code solving a real world problem
19 Apr 2023 by shivangkaul
I have two separate project, one is WebAPI developed in .net Core 2.2 with Windows Authentication and other is Angular. I am stuck in CORS issue. I was able to handle GET request by using withCredentials: true in GET method option as mentioned...
19 Apr 2023 by Marcin Xyz
In ASP.Net Web API, .Net 7.0 + Angular I had exactly the same situation. GET requests worked, but on POST requests I was receiving error (visible in the console): Quote: Access to XMLHttpRequest at from origin has been blocked by CORS policy:...
12 Apr 2023 by manuel_joseph
How to clear selected records on button click event in angular addDisplayAttrToDetailsGrid(list: any) { let items = this.addedAttributes ForDetails.filter(i => i.ProductCode == list. ProductCode && i.ScriptName ==list.ScriptNam if...
13 Mar 2023 by Michael Breeden
How to make an API connection (GET, POST) using Salesforce Apex language (very like Java) to a FHIR (Electronic Medical Records) Server
6 Feb 2023 by Ajas Aju
I have the same issue not resolved yet. My API Code: HttpPut("updateThemeDetail/{whiteLabelId}")] public async Task UpdateThemeDetail([FromForm]TenantThemeSetUpInput item, string whiteLabelId) ...
6 Feb 2023 by JayantaChatterjee
Hi All, I created a .net core(v3) Web API and an Angular project, so I trying to send an object which will contain a file and others data (like name, duration etc..). My Angular component code:- saveMovie() { this.submitted = true; if...
24 Jan 2023 by Bal krishna sharma
Actually 500 bad request is shown in the time of Http request method is run using namespace std; const wstring domain = L"localhost"; const wstring requestHeader = L"Content-Type: application/json"; int port = 7276; bool https = true; ...
24 Jan 2023 by Ramesh p
whenever PostAsJsonAsync api failed due to internet disconnect at the time catch block didn't catch the exception. I want to catch the exception if internet disconnected try { Data cus = new Data { Searchterm = searchterm }; ...
24 Jan 2023 by Pete O'Hanlon
Rather than checking response.IsStatusCode, use response.EnsureSuccessStatusCode();. What this does is throw an exception if the status code indicates that the response was not successful. The good news about this is it validates far more than...
3 Jan 2023 by suman palla
Hi Everyone, How to access SSRS Report Server and download Report (.rdl) with dynamic parameters. Currently I am getting the following exception. The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication...
3 Jan 2023 by swapna matanam
Hi Suman, Were you able to fix the NTLM issue, could you please help as am also facing the same issue.
26 Dec 2022 by ahmed_sa
I work on a web application with ASP.NET Core 6 and Angular 13. This application displays a list of items successfully without any issue. My issue happens when there's pagination for the items displayed. I get an error in the console: ERROR...
6 Dec 2022 by Bal krishna sharma
[HttpGet("getDeparts")] public async Task> getDeparts(string DeptName) { User ues = await DBCon.department.Select( s => new User() { id=s.id, ...
4 Dec 2022 by ahmed_sa
I working on .net 5 mvc i have table name cinimas have 5 rows . my issue I can't display these 5 rows on custom view model . I try but no rows display what I try 1- model creation public class Cinema:IEntityBase { [Key] ...
4 Dec 2022 by Richard Deeming
Quote: I check this to return data from model direct it return 5 rows as below as below: var cinmas2 = _context.Cinemas.ToList(); but from view model on step 4 as below no rows displayed: public IQueryable GetAllCinimas() { ...
1 Dec 2022 by ahmed_sa
I work on web application asp.net mvc core .net 5 i can't modify action login to accept 3 login attempt failed only . if he try with wrong password or wrong email account after that then block it . so how to using session to allow user enter...
1 Dec 2022 by Richard Deeming
Configure ASP.NET Core Identity | Microsoft Learn[^] The documentation clearly describes how to enable, configure, and use the lockout feature.
25 Nov 2022 by ahmed_sa
I work on .csharp net core 5 i need to create blazer app with good architecture with clean code are any one know GitHub link source code for that or any sample on internet site i can follow it . What I have tried: sample for blazor good...
25 Nov 2022 by OriginalGriff
To add to what Dave has said, no single example of "clean code with good architecture" applies universally for all projects, even within a single framework like Blazor! What works well for one app would be a disaster for others, and vice versa....
25 Nov 2022 by Dave Kreskowiak
I'm sorry to tell you that just looking at examples is not going to teach you how to write "clean code with good architecture." What you want is a result of proper software design philosophy, which you're not going to learn from looking at some...
24 Nov 2022 by ajay.raju531
Hi, How to send form-data using HttpWebRequest post method. Please check my code and advise me how to set request.ContentLength and pass formData to request. for "x-www-form-urlencoded" content-type, I have used like. Stream requestStream =...
24 Nov 2022 by Richard Deeming
HttpWebRequest is an extremely low-level API, so you have to build the multipart/form-data request yourself. There's an example of how to do that in this SO thread[^] - essentially: string boundary = "---------------------------" +...
23 Nov 2022 by alirıza adıyahşi
Creating a web farm on Docker container using redis, haproxy and abp module zero core template
22 Oct 2022 by ahmed_sa
I work on visual studio 2019 when create new project with .NET core web application it display to me as .NET core 2.1 i need to create new project on visual studio 2019 with .NET core 5.0 so what i do to display .net core 5.0 when create new web...
22 Oct 2022 by Dave Kreskowiak
Chances are you have a global.json file somewhere in directory path you ran the command in that is forcing the 2.x version of .NET. Select which .NET version to use - .NET | Microsoft Learn[^] global.json overview - .NET CLI | Microsoft Learn[^]...
21 Oct 2022 by Chaitanya 2022
I am creating a web application with ASP .Net WEB API for integrating GMail API. I am reading threads then reading messages on each thread id with a loop of threads. It is taking too much loading to get response. Please help me if i did anything...
21 Oct 2022 by OriginalGriff
Threading is not a Magic Bullet that will unconditionally increase your app speed: A thread needs a free core in order to run, so if you spin up X threads and there are X / 2 cores in the machine, you cannot run all thread simultaneously, and at...
17 Oct 2022 by ahmed_sa
I work on iis i need to publish web application angular 11 and asp.net core 3.1 on iis (web api ) are there are any web site or video explain that from scratch please my app contain to web api csharp as backend with angular 11 are there are any...
17 Oct 2022 by Sandeep Mewara
Follow the following knowledgebase articles: Create an ASP.NET Core app with Angular - Visual Studio (Windows) | Microsoft Learn[^] How to Publish Angular with ASP.NET Core - Code Maze[^] You will have to try and resolve the specific issues if...
11 Oct 2022 by Tharakharish
Could someone suggest on below risk raised by checkMarx tool for ASp.NET Core WebAPI, as application don't send or store any cookies. " Startup.cs application configuration file, at line 21, does not define sensitive application cookies with the...
12 Sep 2022 by Manidas Payyoli
Hi I am a Web Api beginner am trying to call one api in another api in asp.net core 3.1. I created two solutions with diffrent port numbers. From httpclient method breakpoint is not going to external api methode.its returning a response as bad...
12 Sep 2022 by Keith Barrow
Bad request is likely to be the JSON message expected by the API doesn't match the one actually being sent. If this is the case, a breakpoint probably won't work as the object passed as a parameter into the Check method can't be created from the...
10 Sep 2022 by prasanna204
hi Friends, I am sending values from windows application to net core web api. I am not receiving values in the API. Getting json deserialize error Is there any alternative to send values to post api from windows applications? What I have...
26 Jul 2022 by DiponRoy
Conversion of complex object to a list of objects
26 Jul 2022 by raddevus
C’YaPass (Fully Open Source Software) now a Fully-Functioning Password Ecosystem which doesn’t store your passwords anywhere — You are the owner of your data.
9 Jul 2022 by Member 8583441
I am designing an api for Educational field. So, I have created WebAPI with authentication mode windows in .Net6. I am having two controllers namely, AuthController and TeacherController. AuthController for authorizing the user and to create JWT...
5 Jul 2022 by Telstra
I have this code in which I am calling a stored procedure and that stored procedure will return 1 or 0 based upon its execution. public async Task CreateData(int id, string name) { return await...
10 Jun 2022 by Jeneesh K. Velayudhan
Hi, I am setting up a project from the scratch. My question is, I'd like to add the react app as a part of the API solution. So that, a full stack developer can work on UI/API at the same time in the single VS instance. The same time, UI...
7 Jun 2022 by Fred Song (Melbourne)
Build a simple finance application with Angular 13 and .NET 6
31 May 2022 by Member 15627495
You're coding in .Net environment : The Memory is often managed and auto-clean ( finalize function in class / dispose for lots of components / and GC as big helper ). As I told you, you evolve in 'network buffer' for request / web server. The...
31 May 2022 by Maarten Kools
We're working on a Web API and need to read (part of) the stream in middleware for logging purposes. I came across the HttpRequestStreamReader[^] at some point, however, I can't find why this would be preferred over a regular StreamReader. Does...
29 May 2022 by Member 11134333
I want to run the .exe from web application. On Button Click I have written the C# code to start the Process. This code is working from my local system when I am running the application from Visual Studio. Exe is executing and showing the...
29 May 2022 by OriginalGriff
We can't help you fix this: we have no access to your server or the app. But ... it's likely a permissions problem. Websites in production run under a special user account, so it may not have the right permissions to access the folder the exe is...
26 May 2022 by Richard-Dev
Hi All, We have a problem with our Web API. When we try to run locally the Web API it is working but when we deploy it on the server it will throw an exception message which is Object reference not set to an instance of an object This is the...
26 May 2022 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
19 May 2022 by Fred Song (Melbourne)
Build a simple finance application with Angular 13 and .NET 6
19 May 2022 by Sabhani Vipul
When i Convert string To Json Object Then Error This type of Error Show.( Cannot deserialize the current json object because(e.g.{"name":"value"}) into type because the type requires a json array (e.g.[1,2,3]) Json String...... { "success": 1, "login": [ { "username": "123456",...
9 May 2022 by Graeme_Grant
"type mismatch during model binding" Firstly, Price value here is a string: "Price": "28.78", Yet you define you proerty in your class as a decimal type. Yes you have a "type mismatch" error. The error message is very explicit: Message=The...
9 May 2022 by Virendra S from Bangalore, Karnataka
public enum SaleType { [EnumMember(Value = "COD")] COD, [EnumMember(Value = "ONLINE")] ONLINE, [EnumMember(Value = "PICKUP")] PICKUP, [EnumMember(Value = "OTHER")] OTHER } ...
9 May 2022 by L Hills
See this page for docs on JsonConverters. For the price, I guess your converter should try to parse whatever is passed in to a decimal and if it can't be done return a default? For discount check for an empty string and return 0.00, presumably.
13 Apr 2022 by ahmed_sa
i work on web page web api and angular 11 this page take input file excel and get result on excel file as output i get error i don't know what is the reason of error and how to solve it error as below Access to XMLHttpRequest at...
1 Apr 2022 by ahmed_sa
I work on asp.net core 2.2 i face issue I can't modify web api to display message "Not Matched Compare" when compare excel function return false (areIdentical == false) . web api below return physical file as zip file in case of compare excel...
9 Mar 2022 by Eliza Maria
Hi! I have an angular 8 dotnet api project in which I have a problem with the post method in register.service.ts as it should return 200 ok,but instead it returns 415 unsupported media type.I am struggling with this error for some time and I...
9 Mar 2022 by Member 15560921
Hi I had almost the same problem but only with string, when i sent it in Postman it was working correct, but in VS Code not. What I did? I added httpOptions httpOptions = { headers : ({'Content-Type': 'application/json'}) } And also...
6 Mar 2022 by Member 15341738
Hello, right now I'm working on a fullstack app (frontend is React.js and backend is .NET Core 3.1 Web API). API is build using CQRS architecture. One of its features is generating an Excel file (in .xlsx format) on backend, which user can...
6 Mar 2022 by Member 9129971
I have a c# webapi having angular web and android, ios apps.I am going to use simple token based authentication.Token is issued at login time and used for future requests.The problem is that how can i devalidate/logout a token of a specific for different devices like web(this also includes...
6 Mar 2022 by Abdo AJ
Hi There ! you already done the half of it you can Store data in JWT such as device unique identifier or any other data that helps you identify the user and get it at every request for the clint side there a payload section at jwt allow you to...
7 Feb 2022 by OriginalGriff
This is one of the most common problems we get asked, and it's also the one we are least equipped to answer, but you are most equipped to answer yourself. Let me just explain what the error means: You have tried to use a variable, property, or a...
24 Jan 2022 by Member 14068594
So I have somebody with some properties in my web API .net 5 c# body payload good: { street_address: "Something", city_town: "Something" } My problem is if someone takes my API and writes properties by hand don't use swagger definition...
22 Jan 2022 by Member 14068594
body payload good: { street_address: "Something", city_town: "Something" } body payload BAD: { street_addres: "Something", city_tawn: "Something" }
17 Jan 2022 by Sadia Rashid Jan2022
I have 4 tables in my database Users, Resources, Roles and a bridge table UserRoles. I have written a PUT Request to update records in User and Resources table and along with it I have multiple entries against Users in UserRoles table which is a...
17 Jan 2022 by Sadia Rashid Jan2022
I solved it using this approach. if it can be of any help to anyone. Thanks :) public async Task DeleteUser(string id) { try { using (hospiceEntities db = new hospiceEntities()) ...
17 Jan 2022 by Sadia Rashid Jan2022
I have 3 tables in my database. Users , Roles and a bridge table UserRoles that has composite PK in it. Now what I want is while deleting the entry from other linked tables I want to delete reference entries from the bridge table as well. ...
11 Jan 2022 by OriginalGriff
The error message "The DELETE statement conflicted with the REFERENCE constraint" means exactly what it says: there is data in another table which references data in one or more of teh rows being deleted. Since this would break referential...
7 Jan 2022 by raddevus
Includes complete C# Web API which allows you to post your app data using simple method
5 Jan 2022 by SajjadZare
I use UnitOfWork with repository in WebAPI dotnet 6 and want to use XUnit for test I use below code but when run the test the result is: System.NullReferenceException : Object reference not set to an instance of an object. What I have tried: ...
5 Jan 2022 by Richard Deeming
That error means you're trying to access a method or property on an object which has not been initialized. At a guess, it's probably the protected readonly DatabaseContext db; field in your UnitOfWork class, which is not initialized by any of...
29 Dec 2021 by Member 15483157
CodeProject - For those who code[^]
29 Dec 2021 by Member 12433411
I have created a Web API and I need to use the "Get" service in an asp web form in a Grid View, how could I do this?What I have tried:I have created a Web API and I need to use the "Get" service in an asp web form in a Grid View, how could I do this?
10 Dec 2021 by .NET- India
Hi, Getting following error in HttpPatch "The JSON value could not be converted to Microsoft.AspNetCore.JsonPatch.JsonPatchDocument" I have created an application and using following code but debug is not being focused on [HttpPatch] ...
10 Dec 2021 by Miguel Hasse de Oliveira
System.Text.Json converter to enable JsonPatchDocument (until it depends on Newtonsoft.Json) · GitHub[^]
26 Nov 2021 by Maxpaine69
Hello all, so im trying to filter que requests to an api, to process some filed in the header, i used ,mapwhen(), i can filter do what i want but then the process doesn continue, basicaly return nothing it doesnt go to the controller. what i...
18 Nov 2021 by L. Michael
Easily create a lean Web API on top of a .NET library of stateless services
19 Oct 2021 by Saineshwar Bageri
Log each request and response of an API in a way that it helps to maintain logs
27 Sep 2021 by Aousaja
In my project I am inserting an employee and as my employee is inserted my save button HTML turns to update and on the back-end I am using the same insert function for updating the employee which I just inserted, my insert functionality is...
27 Sep 2021 by Richard Deeming
Quote: IF EXISTS (SELECT 1 FROM Employee WHERE UserName = @UserName AND pass = @pass AND OfficialEmailAddress = @OfficialEmailAddress AND Department = @Department AND RoleID =...
23 Sep 2021 by nagendrathecoder
Hi All, I am calling microsoft's token API for getting auth token. I am using below code HttpClient httpClient = new HttpClient(); httpClient.DefaultRequestHeaders.Clear(); var keyValues = new List>();...
22 Sep 2021 by saifulhaque
Hi, I am working Web api project.Bearer API token generation working is fine and authetication also working fine.If one user generated Bearer token and expires 90 days .When he generate another token both is working .How we can stop previous...