Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,294,308
Community Members
 
Community Events
165
Community Groups

How to create ticket and comments on behalf of another user via REST API?

I am using a service account and have the use case of creating ticket and comments on behalf of another user via REST API. Currently, I am unable to figure out any API example or way to do the same.

1 answer

Hi @AVNISH ANAND  -- Welcome to the Atlassian Community!

You may want to search in the developer community for ideas about this topic:

https://community.developer.atlassian.com/

Best regards,

Bill

Hey Bill, with all the due respect, that's a pretty useless answer as the general community is now so bloated and full of out-of-date answers that it is not particularly easy to find anything there.

For other people finding this question, here is how far I made it, maybe it will help somebody, or maybe somebody could kick me even further:

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post describes vaguely how to create an issue.

1) First, follow the beginning of that description to get to a point where you have your user credentials

2) Then, replace the xxx with your actual values, and run:

curl --request GET \
--url 'https://xxx.atlassian.net/rest/api/3/issue/createmeta' \
--user 'xxx:xxx' \
--header 'Accept: application/json'

-> it will tell you what are the `issuetype.id`, `project.id` numbers you want in the next step.

3) Run

curl --request POST \
--verbose \
--url 'https://xxx.atlassian.net/rest/api/3/issue' \
--user 'xxx:xxx' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"update": {},
"fields": {
"summary": "Main order flow broken",
"issuetype": {
"id": "XXX"
},
"project": {
"id": "XXX"
},
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"text": "Order entry fails when selecting supplier.",
"type": "text"
}
]
}
]
},
"reporter": {
"id": "XXX"
},
"labels": [
"test"
]
}
}'
sorry for the broken formatting, I'm sure you can prettify it. The code above hasa total of six XXX bits you need to replace with your values.
---
This brings me to how did I even find this discussion thread:
1. I have no idea what my `reporter.id` should be, when I'm creating a new issue on behalf of a random customer
2. The docs don't describe what is the shape of the payloads. Showing a link on a word "object" explaining that additional properties of that object could be "anything" is not technically wrong, but is entirely useless.
I'm sure this is somehow all my fault, caused by lack of knowledge of the API, but all I wanted is to work out what is the API call I need to make to create a ticket on behalf of a website visitor, so that I don't have to send an email, or use one of the ugly data collectors.
To be fair, I expected this to be part of an API that can be used anonymously, since creating an issue through sending an email needs no authentication either. I also expected this to be a single API call with some basic (but documented) JSON body.
Instead I found that I need to bind my own (admin-level) user account with the operation, by creating an API key. Alternatively, I can create a new user, start paying for it, and then use that user to create these tickets. That is, of course, if I ever made it to the point where I actually know what the API call is.
Phew. Sorry for the rant. It's 2022 and APIs should no longer be difficult to use.

Update #1. Changing the `reporter.id` to `reported.email` makes the API call go through, and the issue is created, but the requester is Anonymous.

I could attempt to create the user, but that would definitely mean I need to use API key with significant access. I don't wish to use API key that can manage my Jira users.

Hi Jan, with "reporter.email" I get "anonymous" in the ticket

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS

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