-
-
Notifications
You must be signed in to change notification settings - Fork 1
Handling Responses
Every possible response always contains JSON. And every returned JSON always returns a "success", whether true or false.
If success is true, a "response" parameter is specified. Otherwise, it will not appear.
Status codes also indicate what the issue is.
The server can respond with various different codes. See below for what happened and why.
This means your request worked and is good! Check for a response.
This is sent for one of many reasons:
- A username or uuid parameter was not specified when
POST
ing. - No Method was provided.
- You're doing something really weird with the request, just do it right, please.
This is only sent when a key is required, but the provided key (if any) is incorrect.
This is sent when you try to access a route that isn't configured. If you're getting this after modifying the config, try /jrareload
.
This is sent when you send a request with an invalid or incorrect method.
If the program fails to handle your input, you may get some interesting issues.
Sometimes you may get a "socket hang up":
This means the server was unable to handle your response properly, so it can't even give you one.
Debug steps:
- Set
debug
totrue
inconfig.yml
- Run
/jrareload
- Do your request
- Check your server console
- Copy all lines starting with "Received request" all the way to the end of the WARN stack trace. For example:
[01:34:50 INFO]: [JSONRestAPI] Received request: POST /?key=CHANGE_ME_PLEASE&request=%server_tps_10%&username=ChewLeKitten HTTP/1.1
[01:34:50 INFO]: [JSONRestAPI] Added parameter key with value CHANGE_ME_PLEASE
[01:34:50 INFO]: [JSONRestAPI] Added parameter request with value %server_tps_10%
[01:34:50 INFO]: [JSONRestAPI] Added parameter username with value ChewLeKitten
[01:34:50 INFO]: [JSONRestAPI] Route:
[01:34:50 WARN]: Exception in thread "Thread-23" java.util.UnknownFormatConversionException: Conversion = '}'
[01:34:50 WARN]: at java.base/java.util.Formatter.checkText(Formatter.java:2748)
[01:34:50 WARN]: at java.base/java.util.Formatter.parse(Formatter.java:2734)
[01:34:50 WARN]: at java.base/java.util.Formatter.format(Formatter.java:2671)
[01:34:50 WARN]: at java.base/java.io.PrintWriter.format(PrintWriter.java:991)
[01:34:50 WARN]: at java.base/java.io.PrintWriter.printf(PrintWriter.java:888)
[01:34:50 WARN]: at pw.chew.jsonrestapi.RestServer$ServerResponder.respondOk(RestServer.java:273)
[01:34:50 WARN]: at pw.chew.jsonrestapi.RestServer$ServerResponder.run(RestServer.java:154)
Then take this information and make an issue. Please ensure you are up to date, as well!