Which is a correct HTTP status code for "Error creating resource"? - authentication

I'm developing an application with authentication, and i need to provide a appropriate status code if there is any error when registering an user, for example a database-related error.
I've been researching but i haven't found an appropriate status code.

The purpose of all HTTP errors is to communicate the operation failed. To pick the right HTTP error, you need to know why it failed.
"database-related error" sounds like a server-side bug or problem, so this is likely just a 500.

Related

How to resolve OAuth2 request failed: Service responded with error: 'Service has been disabled for this account.'?

How can I resolve
OAuth2 request failed: Service responded with error: 'Service has been disabled for this account.'
?
I have a Chrome extension that requires a "See, edit, create, and delete all your Google Sheets spreadsheets" sensitive scope. I think maybe some companies block apps with this and this is what is triggering the error.
Do you know if this is the case and how to resolve / maybe do further authentication to remove this error? I was thinking maybe registering on restricted scope .....but honestly not sure if that'll work
I registered sensitive scope but it still seems to be triggering an error for some folks. I think it is a company issue & wondering if others have had this problem and if there's a way to get around this

how to handle http connector response code

Currently in mule, I have a flow process that makes an http connection to elasticsearch. We are using the scroll api and all connections are fine. I am trying to create a flow to handle the 404 status code which would be returned in the event that the scroll_id has expired on a request. At the moment, I added code 404 to the advanced settings for "Failure Status Code Validator" section on the http connector. What I want to accomplish is that when 404 is returned from this particular http call (which we know is due to the scroll_id expiry), we make another http call to another gateway. So when 404, make another http call to a separate link.
Thanks in advance. I am still learning the xml code, but if you have an anypoint studio experience in the GUI that would be extremely helpful.
I accomplished this by setting a success status code validator under the Advanced tab of the http-connector.
Before setting this value, when getting a 404, the mulesoft would raise its default exception for error code 4xx. At the moment, I still can't figure out how to override that or set something additional, and that could be due to this particular project I am taking over. However, in the success code validator section, I set the values to 200,404 which is saying that a status code of 200 and 404 can pass to the next component in the flow. By default, if you don't set 404, again mulesoft will throw its default built in error message for status code 404. So since I am telling mulesoft to treat this as okay, I can pass to the next component in my project. At the next flow immediately after the outbound http call to an external rest service, I have a choice-component in place that is evaluating what the status code of the http call is. To do this, you can use this: #[message.inboundProperties.'http.status' == '404'] which is saying, use this particular flow path if the status code is 404, else use the default path.

401 unauthorized error while creating object in back4app via Temboo

I am creating an object in parse (using back4app parse server for this).
I get the following error when I run the choreo in temboo.
A HTTP Error has occurred: The remote server responded with a status
code of 401. Typically this indicates that an authorization error
occurred while attempting to access the remote resource. The data
returned from the remote server was: {"error":"unauthorized"} . The
error occurred in the HTTPSend (Parse) step.
That 401 error might indicate that the Id or Keys are not correct. Maybe it could be a good idea to double check them.
Also, what is the host and path for the API Request that you're doing with Temboo (I'm not acquainted with it)? If you're not using the correct ones it might cause problems too.
Make sure you're reaching something like this:
https://parseapi.back4app.com/classes/Your_Class_Name

How to show the internal server errors to the user?

I am working in an API . I want to throw detailed error messages to the user. Now i am in a situation to decide what kind of error code should be sent or how to explain user if any error occurs in the application internally. For example if database connection fails , what kind of http status code i want to send to the user ?
Can anyone help ?
An HTTP status code generally refers to the status of the HTTP request itself, not the status of the application handling the request. Therefore, most server-side errors are covered by 500 Internal Server Error. Any additional info about the error should be described in the response body. For APIs, the response body will often be JSON or XML, so you can use those formats for your errors. Something like this:
HTTP/1.1 500 Internal Server Error
[headers]
{"status":"error", "message":"The request failed due to database connectivity."}
There are, however, two cases I can think of when you might want another status code. If the user has requested an API method that is not implemented, you might want a 501 Not Implemented, and when there is a temporary service outage, you can use 503 Service Unavailable.
More info about server-side status codes here.

What are the 404;1, 404;2 etc HTTP error codes for?

In IIS I can configure my custom error pages.
For each HTTP Error code I can say where to go. Several codes have a number of "sub" codes available. For example 404 has a regular 404, 404;1, 404;2 and so on..
What are they for? When are they returned? Should I make custom pages for these errors? Can I somehow easely configure all code "families" to come to the same page?
401 - Access denied. IIS defines several different 401 errors that indicate a more specific cause of the error. These specific error codes are displayed in the browser but are not displayed in the IIS log:
401.1 - Logon failed.
401.2 - Logon failed due to server configuration.
401.3 - Unauthorized due to ACL on resource.
401.4 - Authorization failed by filter.
401.5 - Authorization failed by ISAPI/CGI application.
401.7 – Access denied by URL authorization policy on the Web server (This error code is specific to IIS 6.0.)
Here is the complete list in the MSDN documentation for IIS 5.0 and 6.0 and for IIS 7.0, 7.5 and 8.0.
If you want to show your visitors or users a nice custom message depending on these subcode, you could do it. But you needn't.
"Substatus" error codes are specific to IIS. They are for "internal" logging purposes - whatever the substatus code, it is the the parent error that gets returned to the client (404.2 gets sent back as 404)
They were implemented specifically to reduce the surface area of attack of IIS whilst still providing sysadmins with a meaningful amount of data. Therefore you actively should not send back specific substatus error messages as you will be opening your IIS installation to possible attack.
Reference
This blog article appears to explain a lot of this. Perhaps it can be of help? At the very least, it explains the meaning of the 'sub-codes'.