Questions tagged [web-api]
Specific APIs that communicate over web protocols, such as ASP.net Web API, as well as APIs that are exposed to web pages for network communication or apps for device communication
391 questions
96
votes
15
answers
19k
views
Should we design our code from the beginning to enable unit testing?
There's a debate going on in our team at the moment as to whether modifying code design to allow unit testing is a code smell, or to what extent it can be done without being a code smell. This has ...
75
votes
4
answers
31k
views
Why PATCH method is not idempotent?
I was wondering about this.
Suppose I have a user resource with id and name fields.
If I want to update a field I could just do a PATCH request to the resource like this
PATCH /users/42
{"name&...
60
votes
3
answers
52k
views
Is performance the only reason not to use SignalR (websockets) entirely in lieu of a traditional REST API?
I have used SignalR to achieve real-time messaging functionality in several of my projects. It seems to work reliably and is very easy to learn to use.
The temptation, at least for me, is to abandon ...
49
votes
12
answers
25k
views
How do I manage the technical debate over WCF vs. Web API?
I'm managing a team of like 15 developers now, and we are stuck at a point on choosing the technology, where the team is broken into two completely opposite teams, debating over usage of WCF vs. Web ...
47
votes
7
answers
46k
views
Why do people do REST API's instead of DBAL's?
At the past two companies, I've been at, REST API's exist for querying data via webapp - i.e. instead of having the webapp do SQL directly it calls a REST API and that does the SQL and returns the ...
43
votes
8
answers
173k
views
Use empty string, null or remove empty property in API request/response
When transferring object through an API, as in schemaless JSON format, what is the ideal way to return non-existent string property? I know that there are different ways of doing this as in examples ...
42
votes
1
answer
8k
views
How to design a REST API that can "prompt" the client about long-running operations?
Say you were to develop a REST API that provides access to a set of complex, long-running, operations.
The typical paradigm for an API like this (as I understand it) usually involves (the client) ...
41
votes
3
answers
45k
views
Should we call Web API from MVC application in same solution?
I am working on a project in MVC that has mobile application so one thing is clear that we have to use Web API so it can used in mobile application.
After creating API when we started to develop Web ...
35
votes
5
answers
35k
views
Should I check if something exists in the db and fail fast or wait for db exception
Having two classes:
public class Parent
{
public int Id { get; set; }
public int ChildId { get; set; }
}
public class Child { ... }
When assigning ChildId to Parent should I check first if ...
32
votes
4
answers
37k
views
Why is there no WSDL type support for Web Api?
So I am just getting started with .Net WebApi and one thing that I am noticing straight away is that there is no Contract defining how the API looks and should be consumed (Request/Responses from each ...
31
votes
2
answers
20k
views
Role-based REST API?
I'm building a REST API for which several users with different roles will have access to the resources it contains.
To keep the scope simple let's take the "student/teacher/class" domain:
GET /...
29
votes
3
answers
93k
views
Best practice for REST API call with many parameters
I have a REST API with GETs operations which receive a (long) list of parameters (8 parameters, for example). The aim of this operation is to search and filter elements.
Which is the best practice to ...
27
votes
6
answers
8k
views
Is it ok to have validation layer before access control layer
I am creating an API strcutured web application and in this application we have different layers which are doing their own job.
First layer is Validation layer which validate user input and if it ...
26
votes
3
answers
10k
views
RESTful API: HTTP verbs with shared or specific URLs?
While creating a RESTful API, should I use HTTP Verbs on the same URL (when it's possible) or should I create an specific URL per action?
For example:
GET /items # Read all items
GET /...
23
votes
4
answers
9k
views
Purpose of async/await in web servers
I don't understand why I keep seeing async/await recommended (or sometimes, even enforced) for ASP.NET Core web applications and APIs.
As far as I can tell, every request is already being run on a ...