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

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

Koczka Bence June 1, 2021

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

0 votes
Alex van Vucht (GLiNTECH)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 10, 2021

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
AUG Leaders

Atlassian Community Events