I tested with Postman that my Spring Boot RESTfull API works correctly if I send a PUT request to http://localhost:8080/app with the header Content-Type = application/json and the body {"appName": "Fake app (for testing)"}. The response from this call is a simple random string and the status is "200 OK". I tried to replicate the same request with Codename One without success, I get a Dialog error with the text 400: null. What's wrong in the following code?
public static void registerApp() {
ConnectionRequest request = new ConnectionRequest();
request.setContentType("application/json");
request.setUrl("http://localhost:8080/app");
request.setHttpMethod("PUT");
String appName = Display.getInstance().getProperty("AppName", "");
request.addArgument("appName", appName);
request.addResponseListener((e) -> {
Log.p("App registered");
});
// request will be handled asynchronously
NetworkManager.getInstance().addToQueue(request);
}
I also need to do some operations on the random string returned by the server (on success), but I don't know how to get that string.
