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?
Community moderators have prevented the ability to post new answers.
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..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.