我在list事件api url中被赋予'q'值,因为我需要过滤掉具有相同单词的事件。我在POSTMAN中给了这个url,它运行正常
https://www.googleapis.com/calendar/v3/calendars/primary/events?q=test&maxResults=2500
但是当我使用HTTP URL Connection在java中提供相同的url时,我得到一个空列表
URL host=new URL("https://www.googleapis.com/calendar/v3/calendars/primary/events?q=test&maxResults=2500");
HttpURLConnection hosturl=(HttpURLConnection) host.openConnection();
hosturl.setRequestMethod("GET");
hosturl.setConnectTimeout(15000);
hosturl.setReadTimeout(15000);
hosturl.setDoInput(true);
hosturl.setDoOutput(true);
hosturl.setRequestProperty("authorization","Bearer ya18.GlycBTDFFefffnj4U77Zua2iSxd7dUNgF2UEdeIkNf6b3A5jsXRwgCS5iwLp-Vi4k49xWWtjm78YnNz5ghatN4GH97gokE222ddwewDDFS_Ga3wcHw");
hosturl.setRequestProperty("Content-Type","application/json");
int responseCode=hosturl.getResponseCode();
我在上面代码的最后一行得到了IOException。 请在这件事上给予我帮助!谢谢!