Spring RestTemplate invoking webservice with errors and analyze status code

You need to implement ResponseErrorHandler in order to intercept response code, body, and header when you get non-2xx response codes from the service using rest template. Copy all the information you need, attach it to your custom exception and throw it so that you can catch it in your test. public class CustomResponseErrorHandler implements ResponseErrorHandler … Read more

401 Unauthorized vs 403 Forbidden: Which is the right status code for when the user has not logged in? [duplicate]

The exact satisfying one-time-for-all answer I found is: Short answer: 401 Unauthorized Description: While we know first is authentication (has the user logged-in or not?) and then we will go into authorization (does he have the needed privilege or not?), but here’s the key that makes us mistake: But isn’t “401 Unauthorized” about authorization, not … Read more

Authorization in RESTful HTTP API, 401 WWW-Authenticate

To answer your questions: How to deal with unauthorized requests? The way you described it is pretty much the recommended way for a RESTful service. As far as I can see there is absolutely nothing wrong with that. What WWW-Authenticate header should 401 responses supply? In general the WWW-Authenticate header tells the client what kind … Read more

Is it possible to send a 401 Unauthorized AND redirect (with a Location)?

By definition (see RFC 2616), the HTTP 302 response code is the redirect code. Without it, the location header may be ignored. However, you can send an HTTP 401 response and still display output. Instead of redirecting the user to an error page, you could simply write your content you want to send in the … Read more

Unable to get windows authentication to work through local IIS

You have to whitelist a domain specified in the hosts file in order for windows authentication to work: Click Start, click Run, type regedit, and then click OK. In Registry Editor, locate the following registry key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters Right-click Parameters, click New, and then click DWORD (32-bit) Value. Type DisableStrictNameChecking and press ENTER. Double-click the DisableStrictNameChecking … Read more

How do I get the HTTP status code with jQuery?

this is possible with jQuery $.ajax() method $.ajax(serverUrl, { type: OutageViewModel.Id() == 0 ? “POST” : “PUT”, data: dataToSave, statusCode: { 200: function (response) { alert(‘1’); AfterSavedAll(); }, 201: function (response) { alert(‘1’); AfterSavedAll(); }, 400: function (response) { alert(‘1’); bootbox.alert(‘<span style=”color:Red;”>Error While Saving Outage Entry Please Check</span>’, function () { }); }, 404: function … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)