1,708 questions
19
votes
1
answer
38k
views
How to return status code in response correctly?
So I am learning FastAPI and I am trying to figure out how to return the status code correctly.
I made an endpoint for uploading a file and I want to make a special response in case the file format is ...
1
vote
1
answer
886
views
How to emulate HTTP response from requests_mock post method
I'm trying to test how is @retry.retry decorator for my custom method works. For this I need to emulate the situation when response has HTTP statuses in ranges 2xx, 3xx, 4xx.
Right now I have an ...
0
votes
2
answers
462
views
Why can't I send the response status inside a spawn answer?
In my node Api I use the following function for a specific endpoint in order to create a PDF and return its name:
exports.findOne = (req, res) => {
.
.
.
const { spawn } = require('...
-1
votes
1
answer
376
views
Is catching 4xx errors enough? [closed]
Catching 4xx and 5xx errors seems unnecessary and hard. Is it enough to only catch 4xx errors? When would even a 5xx error appear if I test my code regularly?
2
votes
2
answers
1k
views
How to catch 4xx and 5xx errors in express?
Lets say that a user is creating an account, but the inputs aren't valid, so I send the errors to the frontend and return a 409 status code. But when the error is in the server side, I don't want to ...
0
votes
2
answers
322
views
google nest thermostat user and rate limits
I now have a project about smart air conditioners, hoping to control the central air conditioner through the nest thermostat. I hope that when the data of the nest thermostat changes, it can be ...
2
votes
1
answer
459
views
How to collect HTTP response status using Genie.jl in Julia
How to collect the HTTP response status for a script?
Below is a sample code which will start a server and allow two routes for interaction.
using Genie
import Genie.Router: route
import Genie....
1
vote
1
answer
64
views
How can I avoid the repetition of returning InternalServerError in failure cases? [duplicate]
I'm trying to add a function for error handling to my web app and instead of doing this all the time
if err != nil {
http.Error(w, "Internal Server Error", 500)
return
}
do something ...
0
votes
0
answers
69
views
How to set up the conditions to test web pages for HTTP status codes 403, 404, 500, 503
I developed a web application with Java (Struts 2) and Web Experience Toolkit (WET - https://github.com/wet-boew/wet-boew), which is running on the WebLogic 12c server.
When any one of the HTTP status ...
0
votes
1
answer
937
views
HttpStatus code in case of update operation but no row gets updated
I am trying to update a resource in DB via @PutMapping (org.springframework.web.bind.annotation.PutMapping) by calling a stored procedure via (java.sql.PreparedStatement.executeUpdate()). This step is ...
1
vote
1
answer
969
views
Get status code when making REST call using Azure CLI
I am making a rest call using AzCli to get the backup configuration of the web apps. However there are couple of scenarios which I want to consider while making this REST call.
To get the state of the ...
0
votes
1
answer
44
views
MoSKito monitor: how to collect response status codes?
I have anotheria/moskito already integrated into the project. It collects and plots the quantity of requests to some REST API endpoints.
Anybody knows how should I tune/adjust it to collect response ...
0
votes
1
answer
2k
views
What HTTP status code for a PUT to a data that cannot be modified?
I need you to help me to decide what HTTP status code I should use.
I have data that I want to modify with a PUT request. This data have different states possible:
draft, toConfirm,confirmed,refuse ...
0
votes
2
answers
649
views
How to get status code from response API without Http Get using KlaviyoClient?
I am using a third party API and want to get the status code response from this.
It doesn't use the usual http.get(request, header) format.
How would we get the status code from this?
This is the link ...
0
votes
0
answers
2k
views
Python Requests: 'The Authorization header is missing'
I'm trying to make an username checker for Ubisoft using Python's requests.
When I run my code I always get a status code 200, which should indicate that the username is available, even when the ...
0
votes
0
answers
233
views
Relative URL in the location header is not handled in HTTP client C#
I used HTTP client to get the status of the URL. By Default the AllowAutoRedirect is True.
It automatically process the URL redirection. But it fails if the location header returns the absolute URL.
...
0
votes
1
answer
15
views
What status code represents : POST failed to edit because too many entries?
400 error codes confuse me and I'm not sure which this corresponds to! What status code represents : POST failed to edit because too many entries?
0
votes
1
answer
1k
views
How to override Django's default response code?
I have two classes in my views.py to handle GET all users, GET one user and POST a new user. If I try to post a user with an id that already exists, Django throws the default 400 - bad request -error. ...
0
votes
2
answers
2k
views
How do I make a username-checker in Python using status-codes?
I'm trying to make a program that checks username availability on Ubisoft.com.
I tried to do this by entering a profile URL letting the code check whether the site gives a 200- or a 404 status code, ...
0
votes
1
answer
1k
views
AttributeError: module 'urllib.response' has no attribute 'status_code'
I'm new to python and working on a python project that checks username availability on Ubisoft.com. I'm trying to do this by entering a wordlist of possible usernames and letting the code check wether ...
0
votes
1
answer
240
views
Why PHP $_SESSION variable not working when being used in header() method?
Recently, I came across a weird contrast while developing a PHP script.
The point is, I want to send an HTTP response status code to another page using the global $_SESSION variable. Then on the ...
0
votes
0
answers
596
views
Is this the correct way to calculate the availability of a web site by using all non-5xx http status codes / all status codes?
I was asked to calculate the availability of a web site by using a simple way: use all the non-5xx http status codes / all status codes.
Is this correct? I'm new to this concept, so any response is ...
1
vote
2
answers
1k
views
HTTP error code for "another operation in progress"
My app handles some HTTP requests which needs more time to complete. When request is successfully enqueued, app responds with 202 Accepted code. However there may be a case when another request is ...
0
votes
1
answer
916
views
Set http status code to 417 when request API with wrong custom header
I have an API (based on dotnet core 5 if it matters) that supports multi tenancy. all requests must have a custom header (like X) that indicates the selected tenant.
So based on this scenario I have ...
2
votes
2
answers
1k
views
what is appropriate status code for wrong email/username when user tries to reset password?
a simple use case - unlogged user tries to reset their password. they provide wrong email or username (but the format of the data is correct).
should I return 400, 412 or 404?
0
votes
2
answers
133
views
How to drip-feed/schedule a Google Sheets script for http status on multiple urls
I have a google sheets script setup that checks multiple urls for their http server status.
function getStatusCode(url){
var options = {
'muteHttpExceptions': true,
'followRedirects': ...
0
votes
1
answer
948
views
How to handling bad request in REST service
I have a rest service that receives an object like this:
public class Item implements Serializable{
private static final long serialVersionUID = 1L;
@Id
private String ID;
...
0
votes
0
answers
2k
views
Does graphql server always return 500 even if its a client error?
I ran a graphql query with wrong input parameters, but still I got 500 response code. It should have been 400 (Bad request) as per my understanding. Can anyone please throw some light on this?
0
votes
2
answers
164
views
Why I'm taking httpStatus:401 or httpStatus 500 with HttpUrlConnection Java?
I'm try to post request with HttpURLConnection
This is request body:
This is request header:
This is my Code:
public static String postSms(long mNo,long cepNo, String mesaj){
...
0
votes
1
answer
1k
views
Correct HTTP REST API status code for incorrect CSV file upload
I'm currently consuming a REST API endpoint for bulk creation of entities via csv file upload.
POST /entity/csv
Content-Type: multipart/form-data
With form-data:
key
value
file
binary
The backend is ...
1
vote
1
answer
2k
views
HTTP status code for item being processed
I have a single end point of a web service where you can queue items for processing by a bot. The items are queued, so it can take quite a while before they are actually processed.
If someone make a ...
0
votes
0
answers
366
views
Jersey/JAX-RS WriterInterceptor and HTTP Status
I have a problem with Jersey, I am writing a WriterInterceptor which should save the answer to the database, the problem is that I cannot retrieve the httpstatus, to avoid saving the answer in case of ...
1
vote
0
answers
609
views
Laravel abort( 404 ) Throwing NotFoundHttpException
When using the following Laravel helper function in a view:
abort( 404 );
Instead of displaying the default Laravel 404 error page, I'm getting:
Symfony\Component\HttpKernel\Exception\...
0
votes
1
answer
4k
views
HTTP 404 versus 596
I noticed that sometimes 596 HTTP status code is used for "Service Not Found". Why is 596 used.
We already have 404 for "Not Found".
I understand 404 is mostly for "Resource ...
2
votes
1
answer
2k
views
Should the HTTP status code for password validation failure be 400?
I have an API endpoint that checks if a password is valid based on a predefined set of password policy rules. When the password conforms to the policy, the endpoint returns 200; otherwise it should ...
0
votes
2
answers
742
views
What HTTP status response code should I return?
What HTTP status code should be sent to the user if his post request is correct but the process got stuck in decision-making(should be made by the client) situation and the client should call the same ...
6
votes
2
answers
9k
views
Handling a 404 error in ASP.NET Core 5 with a custom response class
I'm working on a Web API in ASP.NET Core 5. I want to handle errors within my Web API.
My service has this code. HttpException is a custom Exception I made so I can have control over the Status Code.
...
0
votes
1
answer
8k
views
Junit Test case for httpStatus.OK and httpStatus.Bad_Request
How to test my service class which has storeInDb() method and is returning database model and httpstatus.OK and httpstatus.Bad_Request along with body.
public ResponseEntity storeInDb(ExeEntity model) ...
0
votes
2
answers
2k
views
How to send an error status code like Bad Request (400) from a google script?
This is a doPost function inside a Google App that returns a Hello World message.
function doPost(e){
return ContentService.createTextOutput('Hello World');
}
Now suppose I want to only accept ...
0
votes
1
answer
114
views
In an entity creation request(POST) sent to Rest API, what is the best status code to return if no foreign key is found?
I have a rest api that meets the request for a post like the one below.
POST /api/v1/products HTTP/1.1
Content-Type: application/json
{
"name": "product test",
"...
0
votes
1
answer
77
views
I miss response .status when HTTP response status 400,
my problem is when i use custom axios aka axiosInstance, i only catch res.status == 200, when response is status 400, i can not take res.status and use it.
My config custom axios:
import axios from &...
0
votes
1
answer
2k
views
How to wait for a specific http status code - C# [closed]
I have implemented this code, since 2 weeks now. Since then I am trying to improve my code because sometimes the Task.Delay method is not enough to wait the third party API to send the correct http ...
0
votes
1
answer
98
views
Xamarin.Forms Service return List<T> plus Status Code
This is the code from the service i generated.Everything work fine. I get the list of photos, but i want to get the status_code and make logic in the ViewModel and show message to the user.
public ...
0
votes
1
answer
893
views
Should I return a 404 error on a resource resulting in empty set?
If I have a resource with the following endpoint that lists all items within that resource:
/api/v1/resources
This results in:
[
{
"id": 1,
"value": -100
},
{
&...
0
votes
1
answer
191
views
Status code for a response that work's but doesn't have a answer
I'm current building a API that can return a determinated city based on it name. My code it's working, the problem that i'm facing is the correct status code to use on a request, that fulfilled itself,...
0
votes
2
answers
5k
views
What does "200 connection established" HTTP response status code mean?
I know about 200 OK but what is 200 connection established?
To give some background, I am testing out XMLHTTPRequest in an old firefox browser(version 26 to be exact) and I see this as the response ...
1
vote
2
answers
2k
views
404 vs 204 on GET, PUT, DELETE Methods
If a request want to get/delete/update to a resource which isn't exist, what do you prefer to return? 204 or 404?
Sample: api/blog/{id} can take that requests: GET, DELETE, PUT and api/blog can take ...
0
votes
1
answer
136
views
Mailchimp and httpstatus.io returning a 500 error
Mailchimp and httpstatus.io are returning a 500 error on a URL, but the page is displaying correctly in all the browsers I've tried & the status code when fetching the page using cURL is 200.
...
-1
votes
1
answer
984
views
How to capture the status code of an IActionResult Method return in a variable C#
I have the following method:
public IActionResult DoSomeThing()
{
try
{
Some code...
}
catch (Exception)
{
return BadRequest();
...
-1
votes
1
answer
9k
views
Setting up a status code for a Response Entity
I have the following response:
noResultsResponse.setMessage("No available models");
return ResponseEntity.status(404).body(noResultsResponse);
This works and returns 404 with the correct ...