Example requests - Java

See the below 2 examples on how to use the Brid backend API using Java without implementing our SDK.

GET request example

OkHttpClient client = new OkHttpClient();

        final String url = "https://api.brid.tv/apiv2/players/list/<SITE ID>/1.json";

        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", "Bearer <YOUR AUTH CODE HERE>")
                .addHeader("User-Agent", "Api | BridVideo")
                .addHeader("X-Site", "<YOUR SITE/DOMAIN HERE>")
                .get()
                .build();
        try (Response response = client.newCall(request).execute()) {
            return response.body().string();
        }

POST request example

String json = "{'data[Video][partner_id]': <YOUR_SITE_ID>," +
                "            'data[Video][mp4]': 'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4'," +
                "            'data[Video][name]': 'Java'," +
                "            'data[Video][channel_id]': 13}";

        OkHttpClient client = new OkHttpClient();

        final String url = "https://api.brid.tv/apiv2/players/list/<SITE ID>/1.json";

        final MediaType JSON
                = MediaType.get("application/json; charset=utf-8");

        RequestBody body = RequestBody.create(json, JSON);
        Request request = new Request.Builder()
                .url(url)
                .addHeader("Authorization", "Bearer <YOUR AUTH CODE HERE>")
                .addHeader("User-Agent", "Api | BridVideo")
                .addHeader("X-Site", "<YOUR SITE/DOMAIN HERE>")
                .post(body)
                .build();
        try (Response response = client.newCall(request).execute()) {
            return response.body().string();
        }