Week of 10/3
RapidAPI Attempt (Errors)
Scanner input = new Scanner(System.in);
System.out.print("input a location to see the weather: ");
String translation = input.nextLine();
System.out.println("output:" + translation);
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://mental-health-info-api.p.rapidapi.com/news/thetimes"))
.header("X-RapidAPI-Key", "8d571b2f72msh44f8fd48e083624p19cce1jsnfb1e373c1716")
.header("X-RapidAPI-Host", "mental-health-info-api.p.rapidapi.com")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://personality-traits.p.rapidapi.com/personality"))
.header("content-type", "application/json")
.header("Accept", "application/json")
.header("X-RapidAPI-Key", "8d571b2f72msh44f8fd48e083624p19cce1jsnfb1e373c1716")
.header("X-RapidAPI-Host", "personality-traits.p.rapidapi.com")
.method("POST", HttpRequest.BodyPublishers.ofString("[\r\n {\r\n \"id\": \"1\",\r\n \"language\": \"en\",\r\n \"text\": \" \"\r\n }\r\n]"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());