Questions tagged [rest]
Representational state transfer, or REST, is an architectural style for networking software to transfer information through the web.
1,594 questions
1
vote
4
answers
170
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
340
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
290
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
192
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
270
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
343
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
435
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
418
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 ...
0
votes
3
answers
319
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
458
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
190
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
153
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
84
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" })
...
0
votes
2
answers
145
views
REST URL taxonomy when sensitive data passed in header
If I have a REST endpoint such as /users/{userId}
and I decide to move userId to a header parameter because it is considered senstive data what should the URL now become?
It could be /users/ or /users/...