Hi,
I am using the latest versions of ScriptRunner and Jira Software (Server).
I am trying to fetch data from an External System into Jira using REST API's through ScriptRunner.
External API's seem to work fine when used with the 'Postman' tool and CURL command.
But, when used with ScriptRunner, I am getting the following error:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at org.apache.http.conn.ssl.SSLSocketFactory.createLayeredSocket(SSLSocketFactory.java:570)
The following are the CURL commands that run successfully:
GET Request:
curl -H "Authorization: Bearer sampleToken" https://sample.url.com/employeesapi/api/employees/testuser
POST Request:
curl -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -X POST -d "username=Jira&password=SamplePassword&grant_type=password" https://sample.url.com/securityapi/oauth/token
The following is the script being used with ScriptRunner:
GET Request:
import groovy.json.JsonOutput
import groovyx.net.http.ContentType
import static groovyx.net.http.ContentType.*
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient
import static groovyx.net.http.Method.*
def client = new RESTClient('https://sample.url.com.com/employeesapi/api/employees/testuser')
def token = "SampleToken"
client.setHeaders([
'Accept' : ContentType.JSON,
'Authorization': "Bearer $token"
])
client.get(
contentType: ContentType.JSON
)
POST Request:
import groovy.json.JsonOutput
import groovyx.net.http.ContentType
import static groovyx.net.http.ContentType.*
import groovyx.net.http.HttpResponseDecorator
import groovyx.net.http.RESTClient
import static groovyx.net.http.Method.*
def client = new RESTClient('https://sample.url.com/securityapi/oauth/token')
client.setHeaders([
'Accept' : 'application/json',
'Content-Type': 'application/x-www-form-urlencoded'
])
client.post(
path: 'update.json',
body: [ "username": "Jira", "password": "SamplePassword", "grant_type":"password" ],
requestContentType: URLENC
)
Any ideas or suggestions on getting rid of the SSL error?
Thanks,
Rupa
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.