TLD
TLD

Reputation: 8135

Sending and receiving Json data between 2 play applications

Both applications are written in Play 2.0.4
Application that used for sending Json file:

@BodyParser.Of(play.mvc.BodyParser.Json.class)
    public static Result getJson() {

        ObjectNode result = Json.newObject();

        try {
            result.put("Backend",toJson());
            return ok(result);
        } catch (Exception ex) {
            System.out.println("Exception: " + ex.getMessage());
        }

        return ok(result);

    }


URL:localhost:80/GetJson -> HTML Output: {"status":"OK","message":"Hello Guillaume"}
Can somebody show me how can I get this json data from other play application? (By using POST request). Basically, first app can give Json file to second app by using POST request of second app or second app can get Json data from first app by using Get request.
Thank you very much. P/S I read documentation of Play but honestly I don't understand the Handling a JSON request part.

Upvotes: 0

Views: 386

Answers (1)

Salil
Salil

Reputation: 9722

Since you are just getting the json string from another app and not modifying the state of the server, you should use 'GET' request. You can test this api using whatever endpoint you mapped it to in config/routes.

Upvotes: 0

Related Questions