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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

How to set reporter on an issue created via Jira Rest API

I am using Jira Rest API to create issues. I need to set a reporter for each issue using rest API.

Below is the body parameter which I am creating to use in the API

json_object = {"fields":{"project":{"key":"IM"},"reporter": { "name": "Gloria Laureano" },"summary":"Testing Jira Data","description":"this is the test jira issue testing","issuetype":{"name":"Client Implementation"}}};

Below is my code to create issue using rest API

headers.put("Content-Type","application/json");
headers.put("Authorization","Basic c2hyYWRkaGFAY3JtLW1hc3RlcnMuY29tOmRPaVN1eGtkZmVtUG85TnY5YUZGMUEzMA==");
json_object = {"fields":{"project":{"key":"IM"},"reporter": { "name": "Gloria Laureano" },"summary":"Testing Jira Data","description":"this is the test jira issue testing","issuetype":{"name":"Client Implementation"}}};
jiradata = invokeurl
[
url :"https://b2bsoft.atlassian.net/rest/api/2/issue"
type :POST
parameters:json_object.toString()
headers:headers
];

 

But I am getting error while hitting this. the error which I am getting is 

{"errorMessages":[],"errors":{"reporter":"Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."}}.

I am not able to understand what I am doing wrong. So please help me how to set the reporter using API.

2 answers

0 votes
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 16, 2022

Hi @Shraddha Jaiswal and welcome to the community,

Why are you using rest/2 when there is rest/3?

Use this http request and set the reporter from the beginning:

POST /rest/api/3/issue

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post

Add this below your "fields", while changing the id with the one you want:

"reporter": { "id": "5b10a2844c20165700ede21g" }

Hi @Alex Koxaras _Relational_ 

How I will get the reporter ID? 

I am using JIRA REST API under the ZOHO CRM script. So the ZOHO USERS will be the reporter on JIRA.

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 15, 2022

You have to know each user's id separately from Jira. If you go to your Jira and go to a user, you will see his/her id on the browser url with a format like 

5b10a2844c20165700ede21g

Hi @Alex Koxaras _Relational_ 

Is there any Jira API to get the user's Id? As I am using API to create the issue on JIRA.

Please help me to get the API as I am stuck to get the user id.

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Dec 15, 2022

This maybe

https://developer.atlassian.com/cloud/admin/organization/rest/api-group-users/#api-orgs-orgid-users-get

I'm not aware of an endpoint to get the reporter/assignee ID per se. I mean if you query an issue with an API request, its payload would be something like the following:

"reporter"{
"self": "https://koxaras.atlassian.net/rest/api/3/user?accountId=7f9fb1f1c2e53906667adf321",
"accountId": "7f9fb1f1c2e53906667adf321",
"emailAddress": "akoxaras@cententia.com",

Hi @Alex Koxaras _Relational_ 

I am using the Authorization Code Flow to generate an Access token and refresh token.

Firstly I am sending the authorization URL:

https://YOUR_DOMAIN/authorize? response_type=code& client_id=YOUR_CLIENT_ID& redirect_uri=https://YOUR_APP/callback& scope={scope}& audience={apiAudience}& state={state}

From the above URL response, I am getting the Authorization Code. 

Next, I need to POST the Token URL which is 

curl --request POST \ --url 'https://YOUR_DOMAIN/oauth/token' \ --header 'content-type: application/x-www-form-urlencoded' \ --data grant_type=authorization_code \ --data 'client_id=YOUR_CLIENT_ID' \ --data 'client_secret={yourClientSecret}' \ --data 'code=yourAuthorizationCode}' \ --data 'redirect_uri=https://YOUR_APP/callback'

I am getting a response with a payload containing access_tokenexpires_in, scope, and token_type values:

{
"access_token": "eyJz93a...k4laUWw",
"expires_in": 3600,
"token_type": "Bearer",
"scope": "delete:issue:jira write:issue-link-type:jira read:project:jira read:project-category:jira write:project-category:jira write:issue-type:jira write:issue:jira read:account write:issue-link:jira delete:project-category:jira delete:issue-link-type:jira read:issue-type:jira read:issue:jira read:me delete:issue-link:jira delete:issue-type:jira write:project:jira read:issue-link-type:jira read:issue-link:jira delete:project:jira"
}

But I want a refresh token also. I need to use a refresh token to get another access token and refresh token pair.

So, Please guide me how I can get the refresh token also.

0 votes
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Nov 11, 2022

Hi @Shraddha Jaiswal 

You could try the call /rest/api/2/issue/createmeta 

This will show you all the fields that Jira will accept when creating a ticket via REST API. I would definitely expect reporter to be in there.

Check the user calling the REST API has Modify Reporter permissions on the target project.

If those steps aren't the solution. Try ensuring the Reporter is on the create, edit screens.

@Tom Lister  Hi, how can I know the reporter I'm setting is on the edit/create screens ? Like do I need to give that user the permission  whom I'm going to be selected as a reporter ?

 

Or do I need to provide permission to the user whose API keys I'm using while setting other reporters ?

Suggest an answer

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

Atlassian Community Events