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

370 questions
95
votes
15 answers

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 come about because we're only just starting to put…
Lee
  • 1,101
  • 1
  • 8
  • 11
70
votes
4 answers

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": "john doe"} And then the application will update…
seldon
  • 952
  • 1
  • 7
  • 13
58
votes
2 answers

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 developing a Web API service and use SignalR for…
tacos_tacos_tacos
  • 1,071
  • 1
  • 9
  • 16
49
votes
12 answers

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 API. Team A which supports usage of Web API,…
Saeed Neamati
  • 18,142
  • 23
  • 87
  • 125
43
votes
7 answers

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 result. My question is - why is this done? If it was…
neubert
  • 568
  • 1
  • 5
  • 7
42
votes
1 answer

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) making a request to the server, asking it to perform…
meci
  • 531
  • 5
  • 5
41
votes
3 answers

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 site we are confused and had discussion on whether…
40
votes
8 answers

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 in the listed links below. Avoid null Return…
imel96
  • 3,488
  • 1
  • 18
  • 28
34
votes
5 answers

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 it exists in the DB or wait for the DB to throw…
Konrad
  • 1,529
  • 2
  • 17
  • 32
33
votes
4 answers

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 Action), this is usually in the form of a WSDL…
shenku
  • 476
  • 1
  • 4
  • 7
31
votes
2 answers

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 /students is the resource to access. Users might have…
Casper Jensen
  • 413
  • 1
  • 4
  • 6
27
votes
6 answers

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 passes the validation we move that to second layer…
Muhammad
  • 399
  • 3
  • 7
26
votes
3 answers

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 manage this scenario?: (1) Receive a list of…
Jose Alonso Monge
  • 369
  • 1
  • 3
  • 5
26
votes
3 answers

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 /items/:id # Read one item POST /items #…
53777A
  • 1,706
  • 13
  • 18
21
votes
2 answers

Isn't CQRS overengineering?

I still remember good old days of repositories. But repositories used to grow ugly with time. Then CQRS got mainstream. They were nice, they were a breath of fresh air. But recently I've been asking myself again and again why don't I keep the logic…
SiberianGuy
  • 4,753
  • 6
  • 34
  • 46
1
2 3
24 25