Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Salesforce - Jira Integration, pass variable into json body

Alec Jasanovsky
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2018

Howdy Guys and Gals,

 

So I'm working on developing an API solution to make callouts from salesforce to create issues in jira.

I've successfully been able to make test cases by hard-coding the json request body: request.setBody('{"fields": {"project":{"key": "SAL"},"summary": "subject","description": "test","issuetype": {"name": "Bug"}}}');

However, when I try to use a variable, like the body of the case. I get no results. So how do I successfully reference a variable to the json body above? 

 

Thanks! Please no suggestions for addons! 

1 answer

1 accepted

0 votes
Answer accepted
Alec Jasanovsky
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2018

Figured it out. Java doesn't support string interpolation, so you must use this format:

request.setBody('{"fields": {"project":{"key": "SAL"},"summary":" ' + subject + ' ".....

 

So to use a variable, use " ' + VARIABLENAME + ' "

 

Thanks me. 

Suggest an answer

Log in or Sign up to answer