Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

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

I am trying to access rules of a transition via jira rest api

Ankit kharola March 4, 2025

Hello, i am currently trying to transition status of an issue through jira rest api but i would like to get the rules of the transition first so we can let user enter the appropriate input that is needed for the transition i am trying to access via

 

resolver.define("workflowRules", async (req) => {

  const { types } = req.payload;

  // Extract types from the request context

  console.log(types, "types");

  try {

    const response = await api

      .asUser()

      .requestJira(route`/rest/api/3/workflow/rule/config?types=${types}`, {

        headers: { Accept: "application/json" },

      });

    console.log(response, "rulesss");

    if (response.status === 200) {

      const data = await response.json();

      console.log(data, "rules");

      return data;

    } else {

      console.error(`Error: ${response.status} ${response.statusText}`);

      return { error: `Error: ${response.status} ${response.statusText}` };

    }

  } catch (error) {

    console.error("Error fetching workflow transition rules:", error);

    return { error: "Error fetching workflow transition rules" };

  }

});

 

but i am getting empty array in return even though i have made a workflow which has some validators and post functions i also trie making the api call via asApp but was getting 503 error

1 answer

1 accepted

0 votes
Answer accepted
Akash Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2025

@Ankit kharola It seems you are trying to fetch this data in your Forge application. Could you please share the output for the below statement,

  console.log(types, "types");

Also, the REST endpoint used in your code requires the manage:jira-configuration classic scope for the app. Could you please check your manifest.yml file and confirm whether your app includes this scope? If the scope is missing, please add it to the manifest, then deploy the changes to apply the update.

Ankit kharola March 4, 2025

Hello @Akash Singh Thank you for the response yes i am using manage:jira-configuration in my manifest file  the output for console.log(types) is [ 'postfunction', 'condition', 'validator' ] types. when i try to get the JSON in the browser i get only app can access these resource but when make the api call asApp i get 503 error 

Akash Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2025

@Ankit kharola After thoroughly reviewing the API documentation, I found that this endpoint only returns workflow transition rules that were created by the calling app itself. It does not return any rules created directly by admins through the Jira product UI.

Could you please confirm if there are any workflows in your instance with transition rules that were created by the app?

If you are only trying to fetch system transition rules for all the workflows in your instance then using the below endpoint would be the best, keep in mind that this returns a paginated response so you might you to make subsequent requests to fetch entire data.

/rest/api/3/workflow/search?expand=transition.rules
Ankit kharola March 4, 2025

@Akash Singh  no the transition rules were not created by the app rules were added in the workflow by me manually is there an endpoint where i could get the rules of a transition i am currently working on a app to change the status of an issue and i would like to fetch the rules before i transition the issue 

Akash Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2025

@Ankit kharola In that case, it would be best to use the endpoint I shared in my previous response.

Ankit kharola March 4, 2025

@Akash Singh  thank you for the response that helped a lot 

Akash Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2025

@Ankit kharola If that resolves your query, could you please mark my answer as accepted? This would also help others in the community who might face a similar situation in the future.

Ankit kharola March 4, 2025

@Akash Singh thank you

Akash Singh
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 4, 2025

@Ankit kharola Please refrain from posting confidential information such as API tokens on community posts. I have omitted the token from your reply and modified your answer for now.

To answer your question, please make sure manage:jira-project classic scope is present in your app manifest as it is needed for the endpoint.

Ankit kharola March 4, 2025

@Akash Singh  i apologise for that i will keep that in mind for next time Thank you for your answer it helped me understand it 

Suggest an answer

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

Atlassian Community Events