java - Java 通过 SSO 从 Rest API Jira 获取 json
问题描述
我想从我们的 Jira API Rest 中获取数据。有 SSO,我会自动使用我的 Windows 用户登录。
当我调用主页(https://jira.f.bbg/rest/api/2/search?jql)时: - 使用我的 java 代码: {"startAt":0,"maxResults":50,"total": 0,"issues":[]} - 在私人导航中使用我的浏览器:{"startAt":0,"maxResults":50,"total":0,"issues":[]} - 使用我的浏览器:我得到了我想从 api 获得的数据
当我使用参数(https://jira.f.bbg/rest/api/2/search?jql=project=PARE2)调用 API 时: - 使用我的 java 代码:java.io.IOException:服务器返回 HTTP 响应代码:400 - 在私人导航中使用浏览器:{“errorMessages”:[“La valeur 'PARE2' n'existe pas pour le champ'project'。”],“错误”:{}} - 使用我的浏览器:我得到了我想从 api 获得的数据
我尝试了很多东西,一开始遇到 SSL 问题,我使用了 jks,现在可以了。我真的不明白为什么我无法获取数据,以及为什么当我有 url 参数时出现错误 400 :(
public String recuperer(String adresse) throws Exception {
URL url = new URL(adresse);
HttpsURLConnection.setDefaultSSLSocketFactory(SecuriteHelper.getSslContext().getSocketFactory());
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
con.setRequestMethod("GET");
con.setRequestProperty("Accept-Charset", "UTF-8");
con.setRequestProperty("Accept", "application/json");
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
for (String line; (line = reader.readLine()) != null;) {
sb.append(line);
}
return sb.toString();
}
解决方案
推荐阅读
- python - 如果在该实例中写入 csv 文件,如何不读取它?
- azure - Azure 帮助:你的登录被阻止
- mysql - 使用 DB::select + binding 也选择一行
- angular - angular http get 在请求中将正文参数作为 json 发送
- c# - Unity - 仅影响单击的游戏对象
- ios - 应用程序崩溃,Xcode 11.5,Swift 5. NSInternalInconsistencyException .... 改用窗口场景上的 statusBarManager 对象
- c - 对于 pset1 中的现金问题,如何使输出正常工作?
- php - 阻止用户多次点赞帖子
- php - 文件夹中的图像幻灯片 [仅限 PHP]
- python-3.x - 在 billboard.py python 包的搜索结果中添加歌词