Questions tagged [http-response]
The http-response tag has no usage guidance.
65
questions
0
votes
0
answers
17
views
Designing an Accepted/202 endpoint
I have an end point where a user can start an update operation. I don't want to make the user wait for the result. There are two possible outcomes:
The action is succesful - nothing to do for the ...
2
votes
2
answers
1k
views
What's the proper response when I try to update an existing entity but with not found parent ID
I have an update API (PUT/PATCH) entity/{id} to update a certain entity in my DB. Let's say:
entity {
id: number, // Primary key, unique, not null
content: text,
parentId: number // Foreign key, ...
0
votes
1
answer
111
views
HTTP error 404 or 500 from an internal call to a separate API?
I have an endpoint in API 1 (my api) that queries API 2 (another companies api) to view and edit objects stored in API 2's database. API 1 is essentially acting as a wrapper service around API 2, ...
4
votes
3
answers
1k
views
Error or not error?
I need to implement the following scenarios at the server:
User sent too many answers in a given amount of time, for example, it can't submit more than 3 posts within an hour.
User sent answer with ...
-2
votes
3
answers
1k
views
What HTTP response to return for a patch request with partially correct and partially wrong
I have a campaign, which has URL as a child.
If I make a patch request to add a list of 3 URLs out of which first one is invalid URL, second URL already exists in the campaign and we do not want to ...
-2
votes
2
answers
1k
views
Which HTTP status to return if a downstream service I depend on returned 500 error
My service B is part of a chain of services and calls a downstream service C.
A --> B --> C
Service C is returning HTTP 500 errors for any error it faced, including bad requests or input ...
55
votes
7
answers
10k
views
Why do so many standards for JSON API response formats contain a "success" property in the response body instead of just using HTTP status codes?
I was researching about best practices for standardised JSON response formats for APIs, according to various sources available online general consensus looks something like this:
//Successful request:...
0
votes
3
answers
2k
views
Is a 422 response ever appropriate for a GET request?
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/422
The HyperText Transfer Protocol (HTTP) 422 Unprocessable Entity response status code indicates that the server understands the content ...
-2
votes
1
answer
395
views
Should I use http status code 402 in my api specification for api methods that allow payment?
According to the MDN the http protocol has the 402 status code:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#client_error_responses
And is used for methods that require payment.
Also RFC ...
-1
votes
2
answers
596
views
What's the most appropiate http status code for 'not possible' or 'not available' [closed]
I am working on a booking app where I need to book appointments, I want to return the most appropriate HTTP code that says that the booking slot wanted by the user is not available, that it's not ...
-2
votes
2
answers
159
views
API: should a problem with data be announced by a HTTP code or in the response body?
After years of (amateur, dirty) personal API development I finally decided to follow some best practices.
My problem: the API may have problems, say, retrieving some data. It will gracefully handle ...
-5
votes
1
answer
3k
views
Is it a good practice to return a map or list as HTTP response
The result of processing an HTTP request consists of mappings. Each mapping is from an order number to an object. Is it a good practice to return this as an HTTP response whose body is a Map<String,...
4
votes
4
answers
4k
views
HTTP POST request status 200 vs 204 vs 404
Our POST API takes in an identifier (let's say deviceId) in order to compute the accuracy of the location we have stored for that device in a DB; the result of that compution is then saved in a ...
0
votes
1
answer
44
views
How would you have a fallback for html insert when the html has changed?
Given a website, our customers will pick a spot on their website and we record an xpath to that location.
Our software is DNS integrated, similar to cloudflare, and we manipulate the origin's html ...
0
votes
1
answer
854
views
Most appropriate HTTP return code when record locked for update due to invalid data
Context
Typical restful CRUD service, including PATCH method, whose API validates fields (eg the "name" field may not contain digits).
However, data in the database (from backdoor ETL load) ...
-1
votes
2
answers
1k
views
Http status and reponse in case the API gives out partial response
I have an API whose job is to aggregate resources obtained by calling multiple other APIs and then give out the aggregated response to the client. Currently even if one or more dependent API calls ...
41
votes
4
answers
10k
views
Any technical reason not to use my own HTTP response code TEXT if I develop both server & Client?
Over the years, I have seen quite a few questions on this site along the lines of "can I invent my own HTTP response codes"? Generally asked by those who are developing both the server and client. The ...
6
votes
1
answer
835
views
Whatever happened to HTTP SEARCH? [closed]
It seems 5 years ago there was a proposal for a HTTP SEARCH request, but it does not appear to have been adopted and it not widely supported. Are there any factual documents or citations which shed ...
10
votes
1
answer
8k
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/...
1
vote
1
answer
302
views
Which HTTP code has higher priority: 403 or 415?
Let's consider the following scenario. I need to access a resource hosted on server X. I want to get this resource in a Y format, so along with my request I send the Accept: Y header. Unfortunately X ...
3
votes
1
answer
468
views
How do I create an HTTP PUT request that modifies the resource in many ways
I have a NodeJs backend that interacts with MySQL database. Let us assume that I have a schema similar to this:
Book
id
name
Author
id
book_id
name
So, I have two tables named Book and ...
-1
votes
2
answers
189
views
What does a proper server response look like? [closed]
tl;dr
Which is the best server response for an endpoint to get a user's age?
30 or {"age":30} or {"metadata":{"time":1561919615,"status":200},"age":30} or something else?
I am writing a server using ...
0
votes
2
answers
921
views
Status code for middleware? 200 or 4XX , 5XX?
I have a design dilemma in deciding the response status code and architecture for a middleware we are designing.
So the Client Calls MiddleWare, And middleware calls the 3rd party service to get car-...
3
votes
2
answers
1k
views
HTTP status 500 for missing file
By default, the HTTP response code for "file not found" has always been 404. I never really thought about it until recently someone was saying that if the missing file is part of an application then ...
-2
votes
2
answers
89
views
REST API acceptable design flexibility
I design and works on lot of projects involves REST APIs. But one question is always occur to me if it is acceptable way to do REST.
So according to REST manuals online, REST is build upon two major ...
1
vote
0
answers
463
views
How to simplify design and remove duplication in java layered architecture?
I've the following project structure (simplified):
domain
dto
view
In domain model is kept. dto classes are used to pass data from domain to view. And in view I've a controller and a handful of *req,...
4
votes
2
answers
653
views
HTTP response header to indicate request was forwarded to another server by reverse proxy
Given a system of services and a reverse proxy, such that requests may either be conclusively processed by the proxy or ultimately handled by any of the services behind the proxy.
Consideration has ...
1
vote
1
answer
2k
views
How to handle API responds with DTO or Error Message
I have a mobile app and an API. The mobile app is set up to expect back a DTO from the API but has no information if an request was unsuccessful.
This needs to be updated so that better messaging is ...
49
votes
11
answers
82k
views
Should a REST API return a 500 Internal Server Error to indicate that a query references an object that does not exist?
I am working with a REST API which resides on a server that handles data for a multitude of IoT devices.
My task is to query the server using the API to collect specific performance information about ...
1
vote
2
answers
2k
views
How to Distinguish When a 404 Status is Real in RESTFul Service
We have ServiceA with these endpoints defined:
/devices:
get:
queryParameters:
make:
type: string
repeat: false
required: false
model:
type: string
...
0
votes
2
answers
1k
views
Including aggregate data in web service response in DDD
I've been struggling with this issue for a while. Let's say you have a business application that has a rich domain and in one of the front-end views you show a list of open Orders. In this view you ...
2
votes
1
answer
430
views
Not prohibited, but disallowed -- which http error code should I return?
I know that if user is forbidden in an admin's area, I should return 401 or 403 status error code. However, what I want to prohibit an admin for accessing a user's dashboard also? An admin has its own ...
3
votes
1
answer
114
views
Meaningful response to the user after his uploaded CSV was processed?
A user uploads a CSV to the server to be inserted into the database and I would like to return a meaningful response to this user.
My thoughts :
{
inserted : x records
discarded : y records
}
...
0
votes
1
answer
1k
views
REST API implementation for graph data - Where to calculate graph units
We have a graph that shows bandwidth usage over time. The bandwidth is returned from the server in bytes.
We need to decide which units to show in the graph in case there are several different ...
70
votes
6
answers
79k
views
Should "No Results" be an error in a RESTful response?
I'll describe an example:
I start making an API for a baking shop. The API will allow people to search their catalogus for baking products, such as home-made minty chocolate chip cookies using api....
3
votes
0
answers
1k
views
pinging vs socket vs push notifications
I develop mobile apps, now im working on a very big project building a tool for the employees to be heavily used. Now the app is on development mode, and testing with few users, but will need to be ...
5
votes
4
answers
2k
views
What are the benefits of using meta tag/JavaScript redirection over HTTP header redirection?
Upon inspecting Twitter's URL shortening service http://t.co, I noticed that, instead of redirecting to the goal URL using a Location HTTP header and a 3xx HTTP status code, it redirects using the ...
1
vote
2
answers
1k
views
Microservices, browsers and HTTP requests
In the old days we used to create a single .gif file for the entire application to avoid too many trips from the browser to the server. Similarly, we used to combine different types of information in ...
0
votes
2
answers
2k
views
Is it acceptable to escalate a software error to HTTP 500?
Should an error 500 only be thrown by the web server, or is it acceptable for your program to throw one itself?
try {
some bad code;
}
catch (Exception) {
set_header_code(500);
set_content_type('...
7
votes
2
answers
151
views
Is repeating an identifier on an API request and response considered a code smell
Is it weird to have an identifier such as (_id) on a request which you send to the API, which "enriches" the request and sends back a response with the same identifier (but obviously more enriched ...
0
votes
1
answer
929
views
Appropriate HTTP status code when authorization server is unavailable
We have authorization server which is in charge of checking token validity, expiration etc. Which HTTP status code should be returned if the authorization server is down?
Should it be 401 with "...
4
votes
4
answers
869
views
Proper RESTful web service response code usage
Assuming I create a RESTful web service that looks up a user in a database given the id as a parameter.
If the user does not exist, should I return a 404 response (because user not found)? Or a 200 ...
5
votes
3
answers
3k
views
Is Model a better place to set HTTP status code?
In MVC usually the controller sets whatever needs to be sent back to the client/View, including HTTP status code, e.g.:
class Controller {
public function get(Request req, Response resp) {
...
2
votes
0
answers
1k
views
How to persist a session cookie in a PSR7 request/response middleware?
I am building a package that implements native-like sessions in a PSR7 middleware architecture.
I created a middleware which is responsible to create and persist a session cookie. The session is also ...
0
votes
2
answers
3k
views
How can I reduce http request while I have hundreds of images and thousands of users [closed]
I need an idea or concept how to reduce http request.
Conditions:
1000s of users(android/iphone) active
100s of small images (150kb/image) to be fetched
Simply by giving each image a hardcoded link, ...
3
votes
2
answers
2k
views
Designing a REST API: setting business logic error codes in http headers or within the response payload
I am designing a REST api backend that is meant to be consumed by a javascript front-end.
I am not sure how to communicate server-side business logic errors (e.g. a user trying to retrieve his ...
2
votes
3
answers
647
views
Store generated image in database or generate it on server/client
I have been thinking what could be the fastest way to show base64/img data to the user, i could generate the data when the user is registered and then store it to database, or generate it every time ...
5
votes
3
answers
3k
views
Web Service and Message Queue
We're looking at creating a web services/REST API layer that will be consumed by web and mobile clients.
To make the solution more robust I was considering putting the commands from PUT, POST, and ...
4
votes
2
answers
2k
views
Do web applications use HTTP as a transport layer, or do they count as an integral part of the HTTP server?
Given an HTTP server (e.g. Apache, IIS) and a web application (user code running in the server using PHP, ASP.NET and the likes), which of those can decide which HTTP status code to return for any ...
3
votes
0
answers
115
views
Response Header for illegal file (format)
I have a simple upload-servlet and need to report if a file is illegal and has not been added.
For some reason i am not allowed to give a html-body back, so i need to use the response-header.
...