http-status-codes

RESTful ajax - which HTTP status code for “item not found”?

怎甘沉沦 提交于 2021-02-10 05:15:12
问题 Lets say I have a single-page web application with a list of items where a user can click on an item to view more info about it. The actual item info is loaded asynchronously, using an AJAX GET request to the URL http://www.example.com/item/[id] and is displayed upon loading. The question is, what to do if the item with the given id doesn't exist? Right now, the request returns status code 200, but the actual content indicates that the item doesn't exist. This seems like a bad idea so I

Django REST framework: how to respond with useful error messages with get_queryset()

巧了我就是萌 提交于 2021-02-08 07:41:36
问题 I have a django model which I want to display via Django Rest framework. I am getting all objects in the model to be displayed via the get_queryset() . However, I also have a couple of query_params which will filter out certain objects. This is my main code which is working fine: class PlanView(generics.ListAPIView): """ API endpoint which allows prices to be viewed or edited """ serializer_class = PlanSerializer permission_classes = (IsAuthenticatedOrReadOnly,) # override method def get

Should non-2xx status code responses include CORS specific headers

帅比萌擦擦* 提交于 2021-02-07 20:15:51
问题 Should non-2XX status code responses still include CORS specific headers such as Access-Control-Allow-Origin , Access-Control-Allow-Methods , and Access-Control-Max-Age ? Does that even make any sense for clients? For example: ➜ api git:(master) ✗ curl -i http://127.0.0.1:9000/dfas HTTP/1.1 404 Not Found Connection: close Server: Node.js v6.3.1 Cache-Control: no-cache, no-store Access-Control-Max-Age: 300 Access-Control-Allow-Origin: * Content-Type: application/json Content-Length: 60 Date:

Should non-2xx status code responses include CORS specific headers

送分小仙女□ 提交于 2021-02-07 20:15:38
问题 Should non-2XX status code responses still include CORS specific headers such as Access-Control-Allow-Origin , Access-Control-Allow-Methods , and Access-Control-Max-Age ? Does that even make any sense for clients? For example: ➜ api git:(master) ✗ curl -i http://127.0.0.1:9000/dfas HTTP/1.1 404 Not Found Connection: close Server: Node.js v6.3.1 Cache-Control: no-cache, no-store Access-Control-Max-Age: 300 Access-Control-Allow-Origin: * Content-Type: application/json Content-Length: 60 Date:

.net core allowing sending back error 401 when using CORS (instead of zero)

蓝咒 提交于 2021-01-29 19:35:55
问题 My client JS app is receiving status code 0 when it is actually 401. When I use postman for running the same request i am getting 401 as expected. I have enabled cors as the following: services.AddCors(o => o.AddPolicy("cors", builder => { builder.WithOrigins("http://localhost:4200") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); })); .... app.UseCors("cors"); The cors is working when there is no authentication problem (401). I am getting error code 0 in the client-side when it is

Fetch 200 Ok status after running Curl Command and using that status write a condition using python in RUNDECK

独自空忆成欢 提交于 2021-01-29 15:19:51
问题 Below is the CURL command which gives the status running in RUNDECK url = "curl -kv https://vn2-lpgdmt-capp99.rno.vzon.com:8990/health/check" My Code is as follows: payload={} Headers={ i have defined here } response = requests.request("GET", url, headers=headers, data = payload,verify=False) status = response.status_code print(status) response_val = response.json() response_val = json.dumps(response_val) if status != 200 : print('********Error in Response***********') print('Status :'+ str

django-rest-framework: Handling business logic and what to return?

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-29 09:18:22
问题 In my API a one can submit "Parent" with 1 child. This is the common use case. You always enter at least one child when entering parent. This is the same on the UI. There can be the case where the user will want to enter a duplicate parent, eg. it already exists in the system. In that case, in the UI, the user gets to choose if he indeed wants to add a duplicate or if he wants to add the child to one of the existing "duplicate" records. I hope this was clear enough. My question is how I can

HttpStatus code 499 is not available in Spring HttpStatus class

余生颓废 提交于 2021-01-29 08:08:37
问题 I am developing a REST API using spring boot. My requirement is "User initiates the process and user cancels the running process any time ". When he/she cancels i am throwing a error message along with the http status code. for this scenario i have decided to use http status code 499 . but this status code is not available in spring framework HttpStatus class? 1.Why this status code is not part of the spring class (org.springframework.http.HttpStatus) any specific reason ? 2.What is the

What HTTP response code to use for failed POST request?

﹥>﹥吖頭↗ 提交于 2021-01-21 07:12:45
问题 What HTTP response code should be returned when a POST request was not successful and a request body was correctly formatted? For successful POST request i am using 201 - Created, but there is no equivalent not created code. I am thinking either 400 - bad request but that would actually point user that a request is poorly formatted or 304 - not modified. 回答1: What HTTP response code should be returned when a POST request was not successful and a request body was correctly formatted? If you

What status code should we return if the POST succeeds but does not result in creating anything new?

∥☆過路亽.° 提交于 2021-01-02 05:32:25
问题 We have an endpoint which when you post create a new version of resource and returns a 201 and the location of the newly created resource. It determines the new version number based on a comparison of the current version and the version being posted (using a semver like ruleset). If the version you post is identical to the existing version then no version number is updated. What should we return in this case? We could just return a 201 even though we have not technically created anything. I