diff --git a/TShockAPI/Rest.cs b/TShockAPI/Rest.cs index 29380cd8..45ccfb43 100644 --- a/TShockAPI/Rest.cs +++ b/TShockAPI/Rest.cs @@ -98,9 +98,9 @@ namespace TShockAPI var obj = ExecuteCommand(com, verbs, e.Request.Parameters); if (obj != null) return obj; - + } - return new Dictionary { { "Error", "Invalid request" } }; + return new Dictionary { { "status", "404" }, {"error", "Specified API endpoint doesn't exist. Refer to the documentation for a list of valid endpoints."} }; } protected virtual object ExecuteCommand(RestCommand cmd, RestVerbs verbs, IParameterCollection parms) diff --git a/TShockAPI/SecureRest.cs b/TShockAPI/SecureRest.cs index 85c36ff2..1aa3a847 100644 --- a/TShockAPI/SecureRest.cs +++ b/TShockAPI/SecureRest.cs @@ -24,7 +24,7 @@ namespace TShockAPI var pass = verbs["password"]; if (Verify != null && !Verify(user, pass)) - return new Dictionary { { "Error", "Failed to verify username/password" } }; + return new Dictionary { { "status", "401" } , { "error", "Invalid username/password combination provided. Please re-submit your query with a correct pair." } }; string hash = string.Empty; var rand = new Random(); @@ -37,7 +37,7 @@ namespace TShockAPI Tokens.Add(hash, new Object()); - return new Dictionary { { "Token", hash } }; ; + return new Dictionary { { "status", "200" } , { "token", hash } }; ; } protected override object ExecuteCommand(RestCommand cmd, RestVerbs verbs, IParameterCollection parms) { @@ -45,11 +45,11 @@ namespace TShockAPI { var strtoken = parms["token"]; if (strtoken == null) - return new Dictionary { { "Error", "Token Missing" } }; + return new Dictionary { { "status", "401" }, { "error", "Not authorized. The specified API endpoint requires a token." } }; object token; if (!Tokens.TryGetValue(strtoken, out token)) - return new Dictionary { { "Error", "Token Invalid" } }; + return new Dictionary { { "status", "403" }, { "error", "Not authorized. The specified API endpoint requires a token, but the provided token was not valid." } }; } return base.ExecuteCommand(cmd, verbs, parms); }