简体   繁体   English

Jira Rest Api的问题

[英]Issue with Jira Rest Api

Problem with using Jira rest API. 使用Jira rest API时出现问题。 I want to hit the jira and has to get the issues,scenarios from jira through java standalone. 我想打jira,必须解决从jira到Java独立的场景的问题。

My company using Jira with SAML and SSO. 我的公司将Jira与SAML和SSO结合使用。 If I directly pass jira url https://jira.mycompany.com and with the basic credentials to the jira rest api it throws "peer not authenticated" exception.Caused by: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated. 如果我直接将jira url https://jira.mycompany.com传递给jira rest api,并使用基本凭据,则会抛出“ peer not authenticated”(对等未认证)异常。原因:javax.net.ssl.SSLPeerUnverifiedException:对等未认证。 when I mouse hover on the JIRA link in my company website it shows the following url. 当我将鼠标悬停在公司网站上的JIRA链接上时,它会显示以下网址。

https://mycompany.com/M2/saml20/logininitial?RequestBinding=HTTPPost&PartnerId=https://jira.mycompany.com/plugins/servlet/samlsso&NameIdFormat=email . https://mycompany.com/M2/saml20/logininitial?RequestBinding=HTTPPost&PartnerId=https://jira.mycompany.com/plugins/servlet/samlsso&NameIdFormat=email

Can some one help me on this how to use jira rest api for this problem? 有人可以帮我解决这个问题如何使用jira rest api吗? Thanks in advance 提前致谢

Its because of the certificate. 其原因是证书。 You need to either provide key to login/ access url in your code. 您需要在代码中提供登录或访问URL的密钥。

I am not sure about java but i have written python script to bypass the certificate verification. 我不确定Java,但我编写了python脚本来绕过证书验证。 Below is the code snipped 下面是代码片段

import urllib2, base64
import requests
import ssl
import json
import os
from pprint import pprint
import getpass

UserName = raw_input("Ener UserName: ")

pswd = getpass.getpass('Password:')

request = urllib2.Request("https://jira.xxx.com/rest/api/2/project")

base64string = base64.encodestring('%s:%s' % (UserName, pswd)).replace('\n', '')
request.add_header("Authorization", "Basic %s" % base64string) 
gcontext = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
result = urllib2.urlopen(request, context=gcontext)

JsonGroupdata = result.read()
jsonToPython = json.loads(JsonGroupdata) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM