From 710726c5efd3e22b687a8c4908a5223c9bae5616 Mon Sep 17 00:00:00 2001 From: "kevin.shehu" Date: Fri, 20 Nov 2020 15:38:37 +0100 Subject: [PATCH] ADD : Api Call on Yookr System --- src/main/java/JSON2RDF/ApiCallYookr.java | 51 ++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/main/java/JSON2RDF/ApiCallYookr.java diff --git a/src/main/java/JSON2RDF/ApiCallYookr.java b/src/main/java/JSON2RDF/ApiCallYookr.java new file mode 100644 index 0000000..2f55898 --- /dev/null +++ b/src/main/java/JSON2RDF/ApiCallYookr.java @@ -0,0 +1,51 @@ +package JSON2RDF; + + +import java.net.URI; +import java.net.URISyntaxException; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.util.Base64; + +public class ApiCallYookr { + public static void main(String[] args) { + + + + //CONFIG PARAMETERS: + //BEGIN------------CONFIG PARAMETERS BELOW TO YOUR ENVIRONMENT--------------------------------------- + String baseURL = "https://api.dev.whysor.com/users/login"; + final String username = "kevin.shehu@hochschule-rhein-waal.de"; + final String password = "DK7SxFkGJgnLhnU3"; + final String body= String.format("{\"email\": \"%s\", \"password\": \"%s\", \"domain\": \"my.dev.yookr.org\"}", username, password); + + var client = HttpClient.newBuilder() + .version(HttpClient.Version.HTTP_1_1) + .followRedirects(HttpClient.Redirect.ALWAYS) + .build(); + HttpRequest request = null; + + try { + request = HttpRequest.newBuilder(new URI(baseURL)) + .POST(HttpRequest.BodyPublishers.ofString(body)) + .setHeader("Content-Type", "application/json") + .setHeader("Accept", "application/json") + .header("Authority","https://api.dev.whysor.com/") + .build(); + + } catch (URISyntaxException e) { + e.printStackTrace(); + } + client.sendAsync(request, HttpResponse.BodyHandlers.ofString()) + .thenApply(HttpResponse::body) + .thenAccept(System.out::println) + .join(); + } + +} + + + + +