ADD : Api Call on Yookr System
This commit is contained in:
		
							
								
								
									
										51
									
								
								src/main/java/JSON2RDF/ApiCallYookr.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/main/java/JSON2RDF/ApiCallYookr.java
									
									
									
									
									
										Normal 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(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
		Reference in New Issue
	
	Block a user