Iterating over JSON and create objects in assets

Dushan Nagahawatta
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 15, 2024

I need to create multiple Asset objects using a JSON response. My JSON response is similar to below. This only create the object for first JSON object. What am I doing wrong?image.png
image.png

 

"status": "OK",
    "response": [
        {
            "devices": [
                {
                    "deviceudid": "F11243C",
                    "serial_number": "C02GN0K1Q6LW"
                },
                {
                    "deviceudid": "63643363E",
                    "serial_number": "11111"
                },
                {
                    "deviceudid": "F346436436D",
                    "serial_number": "12222"
                },
                {
                    "deviceudid": "F3414364747B88",
                    "serial_number": "333"
                },
                {
                    "deviceudid": "F34644C",
                    "serial_number": "444",
                }

      ]
}]

1 comment

Marios Marneros
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.
October 15, 2024

Hey @Dushan Nagahawatta , welcome to the Atlassian Community! Thanks for raising this! You might want to raise it as a Question to get more people to look at this.

I would add a log to check what webResponse.body.request.devices is! From the example JSON you gave above it looks like it should be webResponse.body.request[0].devices but I don't think that is correct! 

What are your logs showing? From what you mentioned above it should be working as expected. Happy to help further!

I found this post where someone is trying to do a similar thing https://community.atlassian.com/t5/Jira-Service-Management/Automation-loop-through-WebResponse-results/qaq-p/2140920

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events