Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Facing issues with using external API's in Scriptrunner Edited

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

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - April 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

273 views 3 20
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you