Questions tagged [rest]
Representational state transfer, or REST, is an architectural style for networking software to transfer information through the web.
1,595 questions
10
votes
5
answers
1k
views
How to deal with public vs private version of same resource in a RESTFul API?
I am having a hard time to deal with one particular issue in API design that might be very common. Let me give the concrete example I have: I am writing a RESTFul API for a store and have the ...
1
vote
5
answers
347
views
Is it good practice to return ApiResponse from a Spring service layer?
I'm working on a Spring Boot application with a VoucherService and VoucherController. I currently have the service method return an ApiResponse<T> directly, like this:
@Transactional
public ...
1
vote
1
answer
388
views
Which approach to specifying a database connection in a web API, is preferred?
Where I work, they have never implemented web APIs. At my previous job, which I left 11 years ago, I would write several web APIs to be used for applications, reports, etc. So when I came to this job ...
1
vote
3
answers
470
views
How to pass arguments of a complex search in RESTful API request params
I’m building an app that lets users manage data across multiple tables. I also expose an API so they can fetch their data and process it in external services.
I’d like to enhance the API to support ...
1
vote
2
answers
274
views
API design: handling multiple user account types
I’m designing a REST API where a single person can hold multiple account types.
For example, one person might have both a CareProvider and a CareSeeker account.
Each account type can have its own ...
2
votes
3
answers
3k
views
POST / PUT with no explicit id in request
In the context of POST/PUT endpoints, is it ok to retrieve the id from the authentication token instead of forcing the user to send it via a path variable?
For example, PUT /api/users that updates the ...
2
votes
3
answers
310
views
Search requests with multiple search values
(related: Fetching records matching multiple joined attributes)
If Spring Data doesn't allow GET requests to have a body (and it's considered bad practice anyway)
curl -X 'GET' \
'http://localhost:...
1
vote
2
answers
412
views
Updating PUT endpoint receiving non-existing id
Imagine an updating PUT endpoint receives a DTO that contains an id that corresponds to no record.
{
id: 12345,
name: "George"
}
Options I see:
Do nothing.
Return an error response.
...
5
votes
3
answers
504
views
When is multiple validation layers of protection necessary?
I'm having a hard time of understanding at what point is multiple layers of validation protection necessary rather than a single point of failure and if the performance hit is a concern
Lets say you ...
1
vote
5
answers
491
views
Conventions and separation of concerns for controllers
I am currently working on a project using .NET APIs and have a few questions regarding controller design. Specifically, I have separate controllers for users and orders, and I am considering the best ...
1
vote
3
answers
382
views
How does HTML-based HATEOAS apply in applications which also want to expose an external API?
I recently read through Hypermedia Systems, and found its arguments incredibly compelling. The book brought a lot of clarity and structure to ideas and frustrations that have been bouncing around in ...
1
vote
1
answer
558
views
3rd party REST API calls in repository pattern
For a long time, I’ve been using Repository pattern to abstract data access logic from actual business logic, always using SQL or noSQL databases as my data source.
But how much valid is it, to ...
-1
votes
1
answer
214
views
Which authentication method to use?
I have a REST API with protected endpoints, which require an AccessToken for access. For the user to receive the AccessToken, they need to access the login endpoint and with the correct credentials (...
2
votes
0
answers
191
views
When Should We Separate DTOs from REST API Serialization Classes? [closed]
We know that combining a domain entity, a DTO, and a REST API serialization class into one won't pass code review:
@JsonInclude(JsonInclude.Include.NON_NULL)
@Data
@Builder
@Entity
@Table(name = "...
1
vote
0
answers
115
views
Best practice: slightly different logic on multi mapping endpoint
Suppose I've got a spring controller as follows:
⋮
@RestController
public class MyController {
⋮
@PostMapping(value = { "publicAPI/addItem", "internalAPI/addItem" })
...