You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
I was able to get the Rest API to GET issues working and get a response of all issues. I am trying to do a POST and create an issue and keep getting 400 bad request. I can't see an error in the json string for the body.
Here is the Salesforce Apex code:
// trying POST to create issue
stringData = '{"update": {}, "fields" : {"project" : {"key" : "IMWW"},"issueType":{"name":"Task"}, "summary" : "Rest test from SF", "description" : "new description from SF to Jira API"}}';
http = new Http();
request = new HttpRequest();
request.setHeader('Content-Type', 'application/json');
request.setHeader('Accept', 'application/json');
request.setHeader('Authorization', 'Basic ' + EncodingUtil.base64Encode(pwBase64) );
request.setEndpoint('https://<mydomain>.atlassian.net/rest/api/latest/issue');
request.setBody(stringData);
request.setMethod('POST');
response = http.send(request);
I added a Sytem.bebug('responseBody=' + response.getBody() ); to my code to get a little more detail.
Despite seeing examples for the json for the issueType as:
"issueType":{"name":"Task"}
This was the incorrect syntax. Two things I had to correct. issueType must be all lower case as "issuetype" and had to use "id" : <actual issuetype id value>
The correct json format for my test create issue should look like:
stringData = '{ "fields" : {"project" : {"key" : "IMWW"},"issuetype":{"id":"10004"}, "summary" : "Rest test from SF", "reporter":{"id":"5f3ecef6fcaf93003bc95ca6"} }}';
The issuetype keyword must be lowercase. I missed this initially. You can provide the issuetype "id" or the "name". Once i corrected and used "issuetype", I could use {"name":"Task"} too.
Also need to include the "reporter" "id" as well.
Hope this helps someone else.
-Mike
Hi @Mike Schumacher ! I am having your same issue. The only blockers I have is.. how di I get my reporter id?
Is there an easy way through the website?
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.