Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JSON body from Automation web request is in wrong format

Björn Gullander
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.
February 10, 2022

I'm trying to use the Cloud automation to get the users from the Jira REST api and then push them into Insight with an External import. However, the result I get from the smart value is transformed into non-JSON.

I'm doing a web request action with URL https://riada-labs.atlassian.net/rest/api/3/users/search 

When logging the response {{webResponse.body}} from the call it has this non-JSON format: 

{self=https://riada-labs.atlassian.net/rest/api/3/user?accountId=557058:48c598a0-ccda-49ca-b1c3-612a3e0df045, accountId=557058:48c598a0-ccda-49ca-b1c3-612a3e0df045, accountType=atlassian, 

when it should be in JSON format (which I get in Postman):

[

{

"self": "https://riada-labs.atlassian.net/rest/api/3/user?accountId=557058:48c598a0-ccda-49ca-b1c3-612a3e0df045",

"accountId": "557058:48c598a0-ccda-49ca-b1c3-612a3e0df045",

"accountType": "atlassian",

"avatarUrls": {

 Am I doing something wrong or how can I get a proper JSON formatted result? As I want to just do another web request with the result, I need to have a correctly formed JSON string. 

2 answers

1 accepted

0 votes
Answer accepted
Prince Nyeche
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.
February 10, 2022

automation for Jira shows you the object how it appears to it as that's how you can access the properties of JSON with automation for Jira. If you're trying to use this object outside of automation to post elsewhere. You should create your own JSON representation by using the dot notation.

[
{
"accountId": {{webResponse.body.accountId}}
}

]
Björn Gullander
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.
February 24, 2022

Hi and thanks @Prince Nyeche 

Weird behaviour that the automation engine reformats the response body. 

However, with your help I got it to work. My JSON looks like this to create a JSON array of users: 

"users": [
{{#webResponse.body.values}} {
"accountId": "{{accountId}}",
"displayName": "{{displayName}}",
"active": "{{active}}"
}{{^last}}, {{/}}
{{/}}
]
micagl admin September 26, 2024

it is not reformatting it, it is decoding JSON to an internal object, where you can access all its elements

0 votes
Kaushik Battu September 3, 2022

Hi @Björn Gullander 

I'm trying to do the same thing. But I'm not able to get web response. Nothing shows when I print {{webResponse.body}} in the log. What Am I missing here?Screenshot 2022-09-03 053259.png

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 4, 2022

Hi @Kaushik Battu,

Your result is [ ], which is an empty list and indicates that there were no results.

Suggest an answer

Log in or Sign up to answer