About this question
I am new to Salesforce with JIRA integration. I have read about them but I have not found any proper documentation supporting the Integration.
Please suggest.
I am new to Salesforce with JIRA integration. I have read about them but I have not found any proper documentation supporting the Integration.
Please suggest.
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask Salesforce Expert
Answered on Feb 9, 2023
For Salesforce-Jira integration. We can use the below code to get the JSON response from Jira REST URL
HttpRequest req = new HttpRequest();
req.setEndpoint();
req.setMethod('GET'); // POST if you want to post data to Jira
HttpResponse res = http.send(req);
Refer here (https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis) to form the REST url. Sample url would look like
http://localhost:2990/jira/rest/api/2/issue/10009
Instead of localhost it should be the domain name your organisation has chosen for Jira.
Then you need to parse the JSON response. Loop through it as shown below and deserialize it (parserJira.readValueAs(issue.class)).
String JSONContent = res.getBody();
JSONParser parse Jira = JSON.createParser(JSONContent);
while (parserJira.nextToken() != null) {
if (parserJira.getCurrentToken() == JSONToken.START_ARRAY) {
while (parserJira.nextToken() != null) {
issue jiraIssue = (issue)parserJira.readValueAs(issue.class);
// Your other code
}
}
}
issue is a class version of the JSON. E.g if the json structure that is returned is of the form {issue:{field1:val1,field2:val2}}; then the class would be,
public class issue{
public string field1;
public string field2;
}
For nested json structure the class structure too have to be created accordingly. There is a tool Json2Apex to map a JSON response to Apex Class. Once the json response is deserialized you can access the values with dot notation on the class object as usual:
....
String issue1 = jiraIssue.field1;
….Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Step-by-step Salesforce guides from industry experts
Common Salesforce interview questions, answered
Guides, tips and career advice on Salesforce from JanBask experts.
Salesforce Entry-Level Salesforce Admin Salary: What Can You Expect to Earn?
Curious what an entry-level Salesforce Admin actually earns? See real salary benchmarks by experience and location, plus how to…
Salesforce Senior Salesforce Admin Salary: Salary Range, Factors & Career Growth
What does a senior Salesforce administrator actually earn? See real salary ranges, the skills that boost pay, and how to move up…
Salesforce Cost of Salesforce Developer Certification: Exam Fees, Retakes & Hidden Costs
The cost of Salesforce developer certification is $200 per exam and $100 to retake. See taxes, discounts, hidden costs, and…
Salesforce Cost for Salesforce Certification: Exam Fees by Type, Retakes & Hidden Costs
Salesforce certification exam fees run $75 to $4,500, and most cost $200. See cost by role, retakes, taxes, discounts, and…