How to use SET to set components via REST API?

adam s July 16, 2018

Documentation for the jira rest api seems to be a mess...  None of the examples work.

 

I was only able to make add and remove verbs work.

 

Can someone please show me the format for using Set to set all components at once?

 

update.components[0].add.name works, but update.components[0].set.name fails.  I want to overwrite all components with the updated list.

1 answer

1 accepted

3 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 17, 2018

That's not the REST API, that looks like some form of library that sits in front of the REST API and provides some coding layer over the top of it.  The REST API would expect an http(s) "put" with a set command embedded in some JSON.

So, which library is it?  JRJC?

adam s July 17, 2018

Im using the rest API.

 

We built a UI in FileMaker and want to push the changes we made to tickets back to jira.  I was just specifying the JSON path i was using to create the JOSN to PUT.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 17, 2018

The code you've given is nothing to do with the REST API, it looks like something that sits in front of it.  The REST API expects a command or JSON.

So, forget it, it's a red-herring.  What JSON are you sending with the put?

Like Dave Menconi likes this
adam s July 17, 2018

This is the JSON that I got to work using the Add verb.

 {"update":{"components":[{"add":{"name":"GAME_UI"}},{"add":{"name":"AUDITLOG"}}]}}

 How would I change that to using the Set verb?  I would like it to overwrite any existing components.

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 17, 2018

You can use the set verb to overwrite existing values:

{
    "update" : {
        "components" : [{"set" : [{"name" : "Engine"}, {"name" : "Trans/A"}]}]
    }
}

That example comes from the 'Setting the components field' in the document: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#editing-an-issue-examples

adam s July 17, 2018

thank you!  that worked!

Suggest an answer

Log in or Sign up to answer