ADD : Api Call on Yookr System

master
Kevin Shehu 2020-11-20 15:38:37 +01:00
parent 6f4f4e0c46
commit 710726c5ef
1 changed files with 51 additions and 0 deletions

View File

@ -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();
}
}