Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Assigning a reporter when creating an issue with rest

James Smyth December 25, 2013

I have website that automatically creates issues in Jira depending on user needs, and I want to assign the currently logged in user as the reporter of the ticket. But simply setting the reporter by name in the fields ends up with a 400 - Bad Request error. I'm putting together request like so:

URL: POST - http://jira.homenet.local:8080/rest/api/2/issue/

{

"fields": {

"summary": "test summary",

"description": "test description",

"reporter": {

"name": "jirauser"

},

"issuetype": {

"id": 10008

},

"project": {

"id": 10000

}

}

}

If I remove the "reporter" area, then it adds the issue with no problem. How can I assign a reporter?

4 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Larry Talley December 25, 2013

It sounds to me like the default behavior should give you what you want. If you have an automated system logging in and creating an issue, then the user which is logged in should be recorded as the reporter of the created issue. You shouldn't have to do that explicitly.

Now if you must do it explicitly... you have probably already checked to confirm that the user your automated process logs in as has the "Modify Reporter" permission. "Modify Reporter" is not a permission granted by default.

I think it is also quite likely that JIRA doesn't allow falsification of the "Reporter" field on create issue. JIRA knows who is logged in when the ticket is created, and, JIRA may insist that the Reporter is created correctly. After a ticket is created, and if authorized via the "Modify Reporter" permission granted to the user or to a group or role which applies to the user, then JIRA will allow the "Reporter" to be modified, but I think it likely that it won't allow it to be falsified on create.

As you can tell this is speculation, I haven't studied the source code for JIRA.

James Smyth December 25, 2013

The "Modify Reporter" permission is indeed set correctly. I can edit the reporter in Jira itself, but I'm able to do so with the REST API. I tried separately posting an update to an existing ticket, but that resulted in a "405 Method Not Allowed".

Edit: After further following of threads, it turned out the user I was using was in the Administrators group like I thought they were..

2 votes
Bryan Karsh
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.
May 19, 2015

Another thing that works – simply add the reporter field to the create screen of your project. Your POST example should then work fine (as long as the user has the right permissions – which you show it to have). I have a script that does this exact thing, and I have no problems with it. 

1 vote
Sumithra Sudhir July 28, 2015

I am creating JIRA issue with REST API. I am using my credentials to create the ticket. The form is on an unauthenticated page and I use my credentials to connect to Jira, but I want the reporter to be the name of the person that fills the form. Is that possible?

 

0 votes
Larry Talley December 26, 2013

One thing you may need to do is use PUT instead of POST.

I downloaded and installed a local JIRA, then added the plugin Rest API Browser (RAB, see blog at http://ffeathers.wordpress.com/tag/rest-api/), and in that tool I can use the REST interface and update the reporter. Here is the JSON that successfully updates the reporter field when using the RAB tool:

{

"fields": {

"reporter": {

"name": "testuser"

}

}

}

But I notice that RAB documents PUT operations and I don't see POST operations.

I can do the same operation from CURL:

curl -u "user:password" -X PUT --data '{"fields":{"reporter":{"name":"ltalley"}}}' -H "Content-Type: application/json" http://localhost:8080/rest/api/2/issue/TEST-1

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events