- Katılım
- 27 Temmuz 2018
- Mesajlar
- 11.204
- Makaleler
- 5
- Çözümler
- 57
Daha fazla
- Cinsiyet
- Erkek
- Meslek
- okuyorum ben ya
Kodum bu. Getter ve setterların olduğu "Transcript" sınıfını atmıyorum.
401 olarak dönüt veriyor. BEdava üyelikteyim ve aylık bin (sanırım, milyon da olabilir) request bedavaydı. Sanırım "post" olarak atıyorum, amacım "get" isteği atmak.
401 olarak dönüt veriyor. BEdava üyelikteyim ve aylık bin (sanırım, milyon da olabilir) request bedavaydı. Sanırım "post" olarak atıyorum, amacım "get" isteği atmak.
[CODE]{"cod":401, "message": "Please note that using One Call 3.0 requires a separate subscription to the One Call by Call plan. Learn more here https://openweathermap.org/price. If you have a valid subscription to the One Call by Call plan, but still receive this error, then please see https://openweathermap.org/faq#error401 for more info."}
[/CODE]
Kod:
import com.google.gson.Gson;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpRequest.*;
import java.net.http.HttpResponse;
public class Main{
public static void main(String[] args) throws Exception {
Transcript transcript = new Transcript();
transcript.setLat("41"); transcript.setLon("29");
Gson gson = new Gson();
String jsonReq = gson.toJson(transcript);
HttpRequest postRequest = HttpRequest.newBuilder()
.uri(new URI("https://api.openweathermap.org/data/3.0/onecall?"))
.header("appid", "rahatlık açısından hardcoded yaptım keyi düzelteceğim orayı").POST( BodyPublishers.ofString(jsonReq)).build();
HttpClient httpClient = HttpClient.newHttpClient();
HttpResponse<String> response = httpClient.send(postRequest, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
System.out.println(postRequest.toString());
}
}