Questions tagged [rest]

Representational state transfer, or REST, is an architectural style for networking software to transfer information through the web.

Filter by
Sorted by
Tagged with
15
votes
3answers
2k views

Versioning REST APIs. Each API has its own version

It's very common to specify the version of REST APIs in the URL, specifically at the beginning of path, i.e. something like: POST /api/v1/accounts GET /api/v1/accounts/details However, I haven't ...
1
vote
4answers
271 views

REST API include permissions into resource

We currently have REST API, where you have a set of different resources, like: GET /cats GET /cats/{catId} GET /dogs Clients decide whether they can perform an action based on resource permissions. ...
8
votes
2answers
4k views

Good way to handle the notification counter like Facebook does

I want to build a similar notification mechanism that Facebook handles. I actually store the user's notification in an SQL table (actually it's a graph database but everybody master RDBMS terms). I'...
2
votes
2answers
300 views

Building a rest api layer on top of a soap webservice

We want to build a rest api layer on top of a soap webservice. Our current situation is that we have a coldfusion application that talks with the webservice, both running on different servers. The ...
2
votes
4answers
344 views

Alternatives to polling an API

Assume we have a desktop application (probably WinForms) that acts as a client to some API for an app with a messaging function. This API has endpoints that return a JSON of messages, and who sent ...
4
votes
3answers
4k views

Integration Testing: Testing Service to Service

I'm looking for some advice on testing strategies for service to service communication. I have one service (service A) that makes a call to another service (B) - which is a rest API. Both services ...
2
votes
2answers
128 views

How to combine session-based authentication and stateless REST API

What is the proper way of combining session-based authentication with stateless, token-based authentication for a REST API? Use case: User logs-in in the standard, traditional, session-based way. ...
117
votes
4answers
63k views

REST API security Stored token vs JWT vs OAuth

I am still trying to find the best security solution for protecting REST API, because the amount of mobile applications and API is increasing every day. I have tried different ways of authentication,...
9
votes
1answer
1k views

Use 404 or 200 when null result (REST) [duplicate]

Let's assume we have an Entity { "id": 1 "inProgress": true, } We have endpoints: /api/v1/entities/ for fetching all entities, /api/v1/entities/1 for fetching entity with id = 1 /api/v1/...
0
votes
2answers
185 views

Is it wrong to build as much granularity as possible into a REST API?

I was recently considering the difference between using raw SQL and using a query builder like knex.js for writing dynamic queries so that I get any level of granularity for filtering database tables. ...
2
votes
1answer
75 views

best way to create @PUT upon multiple entities and compatible with RFC

I am trying to build the best PUT possible that allows modifying multiple entities upon single requests using java jersey. The idea is to send a request with multiple entity ids as @PathParam values ...
3
votes
4answers
15k views

Is it okay to use POST for REST API updates?

For some time I used PUT or PATCH in order to update a REST API resource. After using a lot of PUT/PATCH calls I noticed that "update" could be also done with POST. Here is an example which is ...
11
votes
2answers
4k views

How should I design an ordered list resource in a restful service?

I've run into this same problem over and over again and I haven't found a solution that I really felt was optimal. Say in an app, you have an ordered list and you let the user change that order by ...
16
votes
1answer
39k views

How can I unit-test my REST web service?

I am new to unit testing, I've one REST web method that just calls DB and populates a DTO. Pseudo code is public object GetCustomer(int id) { CustomerDTO objCust = //get from DB return objCust; } ...
6
votes
2answers
3k views

Is it bad practice to call another API from a Filter?

I am using Java, Spring and Jersey. I have a REST API A which receives a query parameter called q and sends this to another API B to get a response. I need to implement a change where I first need ...
8
votes
2answers
854 views

“REST Vs GraphQL” is it a correct comparison?

I saw in many sites that compare REST with GraphQL. after investigating this concern (actually my concern) that, "is it a correct comparison?", I being more confused. Since the REST has a different ...
-4
votes
3answers
78 views

REST API design: Best practice for POST to create an object to a list

I have an API that return list of Employee. This API will have an offset and limit for pagination purpose. On the frontend, I use Single-Page Framework (Vue/Angular/React..). This SPA have a Employee ...
1
vote
1answer
148 views

How should REST resources relate to the server database schema?

I am trying to understand whether resources in a RESTFUL API should directly represent the underlying database or not. In particular, a problem that I have is that I usually use highly normalized ...
2
votes
6answers
533 views

Is building REST API compatible with Agile approach?

I believe I understand what REST is and what Agile is. Our company has some APIs that we maintained, usually we only needed to tweak some requests or responses to fit new requirements. Recently, we ...
2
votes
4answers
3k views

Is creating ViewModels in Web API a bad practice?

So, somebody at work who is twice as experienced than I am, told us that we must not create ViewModel classes within Web API. (We are using Angular for UI) In his opinion ViewModel is ASP.NET MVC ...
0
votes
2answers
182 views

Http Status Code When Downstream Validation Fails

I have an API that charges for an order. It accepts the orderId and the amount as inputs. Then it makes a '/charge' call to the downstream, which returns a 202. Immediately after this call, it calls a ...
1
vote
2answers
608 views

Retry a failed REST API request - Java/Postgres

We have a REST API which calls a third-party REST API to Send Emails. The Third Party API is not super reliable and randomly fails every now and then with a 500. Our Clients do not want to retry at ...
4
votes
2answers
164 views

client / server division of responsibility

It makes sense to give the server applications as much responsibility as possible as to avoid having to rewrite logic across different types of clients. In my case I am developing a data structure ...
2
votes
5answers
428 views

Is it acceptable to accept multiple results in a unit test?

I've noticed this while implementing a Rest-API today. We first define interfaces for each API method and the api contract for one endpoint allows (amongst others) two status codes: 200 and 204. Both ...
3
votes
4answers
562 views

What's the ideal way to send a success message in the response of a HATEOAS Rest Api?

I am using HATEOAS architecture in my rest application and want to send internationalized success message that will be directly consumed by the client. I know we can just add a key in the response but ...
56
votes
5answers
82k views

RESTful API. Should I be returning the object that was created / updated?

I'm designing a RESTful web service using WebApi and was wondering what HTTP responses and response bodies to return when updating / creating objects. For example I can use the POST method to send ...
3
votes
4answers
1k views

Cron Job Microservice

I'm implementing an application that's made of bunch of microservices. Each of them is fairly simple, focusing on its own task. Let's call two of them Service A and Service B. They are both ...
4
votes
0answers
402 views

How to implement SAML Authentication SPA and REST Backend

Developing a SPA (with VueJS) that is talking to our own REST API Backend(Separate server). Normal authentication flow in the SPA: User credentials after submission are sent to the backend and if ...
3
votes
3answers
557 views

REST API: what should PUT do with complex objects?

Let's suppose I have the following objects in my domain: class Warehouse { int Id; string Address; Item[] Inventory; } class Item { int Id; string Name; int Price; int ...
1
vote
1answer
66 views

Abstracting common functionality for REST and CLI

I have made an application that deals with collections of images. Currently it has a REST api to add/remove images, create/clear/delete collections and a worker that can automatically fetch images ...
16
votes
1answer
11k views

RESTful API and i18n: how to design the response?

We are designing a RESTful API that is mainly intended to meet the needs of a single client. Because of its very particular circumstances, this client has to make as few requests as possible. The ...
1
vote
1answer
206 views

Bounded contexts and domain-wide public REST API

I'm prototyping out an application here where I'm using domain-driven design to identify the domain(s) of the application and I've ended up with something that - at least so far - feels like a fairly ...
4
votes
4answers
2k views

Idempotency and concurrency in a REST web service

Is concurrency and idempotency mutually exclusive for a REST web service or can it be done so a service can be both concurrent and idempotent? Using a optimistic lock methodology like using Version ...
1
vote
2answers
2k views

REST API Input Validation Strategy

I am implementing a REST API and need to validate the JSON API inputs for the CREATE and UPDATE endpoints. The goal is to send a 400 error prior to doing any processing if the inputs are not valid. ...
1
vote
2answers
82 views

REST: How to reference existing resources in a HTTP POST request body?

This question relates to a somewhat more specific case than the one discussed in How can I create a RESTful calculator? It should be assumed that the values to be calculated are not simple integers, ...
0
votes
3answers
79 views

Should a composition be considered a resource in REST?

Consider this example system consisting of the following resources: Family, Person and Role. A Family and Person has a many-many relationship and each family member has a certain "role". For example, ...
0
votes
1answer
159 views

Image upload workflow azure

I'm working on a new project. It is a smartphone application made with react-native. In the app, you can create "cards" which are having a title, a description and a photo, taken by the user's phone. ...
1
vote
1answer
22 views

Expose resource as child of its parent or not?

Say every word belongs to a dictionary. What's the preferable URI for a single word, either /word/:word (with dictionary_id a required GET parameter), or /dictionary/:id/word/:word? I'm thinking the ...
0
votes
1answer
73 views

API design refrence , Empty list response (REST, SOAP, …) type compatibility

Not sure where to go for an authoritive/text book answer for this question. Suppose a service returns a list of something e.g. Customer, Employee, Fruits, etc. What should be returned when the list ...
0
votes
1answer
58 views

Should two different set of login APIs follwing REST have write access to the same DB?

Like for example, /api_1/login and /api_2/login writing in the same table of the same database.
4
votes
1answer
1k views

REST API Design: Multiple resources and authorization

I'm working on a service that forwards/unifies our API calls to external platforms/services. For example, let's say that I don't want to handle all possible actions (create post, retrieve post, edit ...
1
vote
1answer
25 views

Represent nested resources that has two different type (entites) owners in REST APIs?

Suppose I have a entity called Appointment. This entity represents an medical appointment between one Doctor and one Patient. To create a new Appointment, I send somethind like: POST /appointments {...
-3
votes
1answer
85 views

An entity belongs to another entity. Should a REST API provide just the ID of its parent, or its endpoint?

Say a dictionary belongs to a language. For the endpoint dictionary/{id}, which is preferable out of: {..., 'language_id': {id}, ...} and: {..., 'language': '/language/{id}', ...} ?
3
votes
3answers
857 views

How to handle “Optimistic Locking” on a collection with ETag headers?

Consider endpoint /projects that returns a list of projects with the following headers: HTTP/1.1 200 OK Etag: "superEtag" The etag value represents a hash of the entire collection and it does not ...
2
votes
2answers
183 views

HTTP 404 for REST calls from client side (browsers)

I'm having troubles with the issue of distinguishing between "real" 404s and 404s where the path is correct but the id, for example, doesn't exist when it comes to client side apps. Most REST ...
1
vote
2answers
189 views

API design for actions (lifecycle, conversion, etc.)

How can I design a good REST API for actions, like in the following cases? lifecycle start a device stop a device ... conversions convert a file from one format to another In both cases I would ...
3
votes
3answers
102 views

Delete user data or replace it with empty resource?

Say, we have a public facing REST API which lets user manipulate data using POST, GET and DELETE. The API is exposed via Service A which at the backend calls Service B where most of the business logic ...
3
votes
2answers
1k views

REST API Structure to request multiple items

I have a REST API that looks something like the below where a person can belong to an organisation (but doesn't have to) and a person has many items. The items may also belong to the organisation ...
1
vote
0answers
59 views

Are REST Resources and GraphQL Object Types conceptually equal?

I'm in the process of outlining the intended business logic of a web service. At this point, I'm not too concerned with implementation details. On the contrary, I'm looking for ways to abstract them ...
0
votes
1answer
61 views

Designing Rest API endpoint for viewing bearer access token

We have several endpoints which were authenticated using a bearer access-token. There was another endpoint which will renew/generate a new bearer access-token on passing valid secret_id and client_id. ...

1 2 3
4
5
26