Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to automate sending large amount of REST API requests, and field changes?

I have an Insight object schema, with an Object in it, called Computer.

This Computer object has 4 fields:

  • Name
  • CPU
  • RAM
  • Owner

All of these fields, except the one called "Name" are empty, and I have to give them value from a separate API endpoint.

I need the "Name" attribute to identify the Computer in the POST request sent to the separate API endpoint, and I need one request for each of the 3 fields I want to populate ( CPU,RAM, Owner),

For example, a request I can make looks like this:
https://separateAPI/api/{{computerName}}/Ram/
which returns the RAM of the computer I'm looking for.

So the problem is, I have lot's of Computers, I am looking for a way to automate sending the API requests for each Computer I have.

After some time of tweaking Automation for Jira, I am starting to think it's not the right tool for this, because I have to manually configure each API request sent out, as an action.

I am looking for an answer, if there is any way to achieve this in Automation in Jira, or which other tool would be able to help me? Or is it the worst case scenario, and I should write my own application for this?

1 answer

The new "When Object Changes" rules are great for bulk automations like this. I have been using the "Status" to manage when these automations are used.

In this response, I am going to assume that your endpoints return the values as a simple JSON object, eg. for RAM: {value:"16GB"}

In your case, I would do something like:

1. When Object is Updated in schema Assets

2. If IQL: objectType = Computer and Status = "Action Needed"

3, 4, & 5. Send outgoing webhooks for CPU, RAM & Owner

6. Edit object:

  • CPU: {{webhookResponses.get(0).body.value}}
  • RAM: {{webhookResponses.get(1).body.value}}
  • Owner: {{webhookResponses.get(2).body.value}}
  • Status: Active

To trigger an update, just do a Bulk Change of the Status attribute to "Action Needed". If you tick the "Allow this rule to be triggered by other rules", you must change the Status to something else at the first Edit Object rule otherwise you'll end up in a loop,

Finally, you may have encountered a particular frustration, which is that you can't call Text functions on Insight attributes. This means you can set the URL to https://separateAPI/api/{{object.Name}}/Ram/ but if you try to do https://separateAPI/api/{{object.Name.urlencode}}/Ram/ then the Name is blank and the request fails. This is because Automation is treating "Name" as if it was another object, and not a Text value.

It took me a few hours to work this out, but you have to dig into the object to get the Text representation of an attribute that allows you to call the Text functions. So this will work:

https://separateAPI/api/{{object.Name.values.get(0).displayValue.urlencode}}/Ram/

Hope this helps!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

Send an Email or Publish to Confluence - What should you do with your release notes?

Background When you hear the words ‘Release notes’, almost always you think of an unsolicited email from a software vendor. But I am here to tell you that from our data, sending release notes via E...

91 views 0 1
Read article

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