It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Assigning a reporter when creating an issue with rest

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

1 vote
Answer accepted

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.

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..

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. 

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

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?

 

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

Community showcase
Published in Jira

[Survey] Development tools and DevOps - share your thoughts!

Hey Community! I work at Atlassian in product marketing and we are conducting a survey to better understand how people feel about their development tool chain and DevOps. We would love if you could...

13 views 0 0
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you