Git Product home page Git Product logo

Comments (3)

deadlysyn avatar deadlysyn commented on August 25, 2024

i must have stared at this too long, and got the opts format wrong above (i think)...i had opts.transition vs opts.issue.transition per function signature/docs. however, this still didn't do it (get 200 OK w/o transition, only comment appears):

  const opts = {
    issueKey,
    issue: {
      update: {
        comment: [
          {
            add: {
              body: 'Test automated comment',
            },
          },
        ],
      },
      transition: {
        id: '21',
      },
    },
  }

i've verified the transitionIds via https://${jiraHost}/rest/api/2/issue/${issueKey}/transitions?expand=transitions.fields. it seems others have problems with transitions using PUT vs POST as well:

for now, i've created a helper function that just uses request to handle transitions (should something like this be added as transitionIssue?):

const transitionIssue = async ({ ...args }) => {
  const { transitionId, issueKey } = args

  const jsonData = `{
    "transition": {
      "id": "${transitionId}"
    }
  }`

  const opts = {
    method: 'POST',
    url: `https://${jiraHost}/rest/api/2/issue/${issueKey}/transitions`,
    auth: {
      username: process.env.JIRA_USERNAME,
      password: process.env.JIRA_PASSWORD,
    },
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
    },
    body: jsonData,
  }

  try {
    await request(opts)
  } catch (e) {
    throw new Error(e.message)
  }
}

from jira-connector.

deadlysyn avatar deadlysyn commented on August 25, 2024

while refactoring some related code, i had a chance to circle back and give this another try. despite my opts.issue.transition looking ok per jira rest docs, it never seems to work with editIssue. i can curl just fine, but need to POST to transitions endpoint vs editIssue's PUT. do you have a good example of how to make this work with editIssue? it would be awesome to be able to remove my one-off request-based function just for transitioning. TIA!

from jira-connector.

deadlysyn avatar deadlysyn commented on August 25, 2024

not sure how i missed transitionIssue when i first searched the repo (saw it in docs but not issue.js :-( ) -- sorry for the noise. i never could get a transition to work with editIssue, but just using addComment + transitionIssue now which is A-O-K.

from jira-connector.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.