Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating JIRA issue via REST API  RSS feed

 
Liutauras Vilda
Marshal
Posts: 4464
299
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers,

I'm having a problem I can't workout. I have a web application to which my current task is to add a feature "1-click create JIRA issue".

I have managed to create an issue from web app by submitting a POST request to JIRA's REST API URI https://jira.companydomain.us/rest/api/2/issue/ by sending JSON with standard most common fields: Project, Issue Type, Summary, Description - all works fine as expected.

Now, for one specific project and issue type, there is another mandatory field which needs to be set, and this is where my problems start.
The fields looks to me as MultiSelect (I don't have a direct access to configuration to confirm that for sure, but after researching, it is the conclusion I came up with as of now).

Since I can't access directly for now JIRA's custom configuration, I've sent a GET request to http://jira.axiomsl.us/rest/api/2/issue/ProjectName_Removed/editmeta, and the field of interest from the response I got I see is in a form of:

Now, reading JIRA's documentation, for MultiSelect field, in order to create an issue, request needs to be sent in a form of:
JIRA's REST API documentation wrote:"customfield_10008": [ {"value": "red" }, {"value": "blue" }, {"value": "green" }]

Probably the difference is, that my field isn't a custom, at least it doesn't look like that.
It didn't work.

Then I realised, that information retrieved about the metadata by sending a GET request specifies, that certain operations are allowed, hence I was trying:
"components": [{"add": {"name": + componentValue + "}}]" Note: quotes are escaped as needed, just removed from here for readability purpose.

By doing so, I get a response with an error, which reads as:
{"errorMessages":[],"errors":{"components":"Component/s is required."}}

Maybe those operations add; set; remove; are for update requests only?


Can somebody please put some light on what I'm doing wrong?

Thanks in advance.
 
Liutauras Vilda
Marshal
Posts: 4464
299
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just worked out. Posting helped me to spot one more thing in metadata and give a try. Instead of using "value" attribute as suggested in documentation...

I did with "id" this time:
"components": [{"id": + componentValue + "}]"

And it worked. Works with "name" instead "id" too.

I really thought I tried that yesterday. Probably needed a break.

JIRA's documentation for creating issue wrote:MultiSelect
"customfield_10008": [ {"value": "red" }, {"value": "blue" }, {"value": "green" }]

I think documentation may mislead. At least it did me.

Thanks for whoever started on looking into this. Solved.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!