Uploaded image for project: 'Automation for Cloud'
  1. Automation for Cloud
  2. AUTO-466

More ways to use code in Automation, e.g. ability to use JSON path expressions to query JSON data in web request responses

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • None
    • None
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

      Currently, if we have a complex JSON response from a web request action, we can only do a simple traversing of it using JSON object notation. However, should there be arrays in the response and we need to get a certain array key, that notation wouldn't work unless we use an array index, which is not ideal.

      For example, if we want to query Insight object attributes, we can send a request to /jira/rest/insight/1.0/object/33542/attributes and then if we need to get this value from the response:

      webhookResponse.body.objectEntries.[0].attributes[?(@.objectTypeAttributeId==3701)].objectAttributeValues[0].user.key

      It is not possible to do that like that. Best we could do is to hard code an array index in smart values:

      webhookResponse.body.objectAttributeValues.get(4).user.key

      But this is far less than ideal.

      A4J should support for flexible querying of the JSON data, such as:

      • possibility to run JSONPath expressions directly on the webhook response
      • possibility to add expressions like "objectTypeAttributeId = xxx" in the smart value syntax.

       

       

      Workaround

      This article provides a workaround for certain cases in the "Filtering without using branching" section.

            [AUTO-466] More ways to use code in Automation, e.g. ability to use JSON path expressions to query JSON data in web request responses

            Christopher added a comment -

            This article provides a workaround for certain cases in the "Filtering without using branching" section.

            Christopher added a comment - This article provides a workaround for certain cases in the "Filtering without using branching" section.

            Anthony Nguyen added a comment - - edited

            Ran into similar problem with Automation and Forms REST API's Get form simplified answers. It's useful information but without a way to query it, it's difficult to actually use. Workaround was to use hardcoded indices.

            Anthony Nguyen added a comment - - edited Ran into similar problem with Automation and Forms REST API's Get form simplified answers . It's useful information but without a way to query it, it's difficult to actually use. Workaround was to use hardcoded indices.

            When we use the REST API for Jira forms.. We get a response that not possible to work with in Jira Automation.  This made FORMS and Jira Automation not useful together.

             

            [{
            2        "label": "Fuel Cards",
            3        "fieldKey": "fuel-cards",
            4        "answer": "Yes",
            5        "choice": "14696"
            6    }, {
            7        "label": "Country",
            8        "fieldKey": "country",
            9        "answer": "Denmark",
            10        "choice": "688731d4-b6e8-41b9-b171-ac575249501d:111894"
            11    }, {
            12        "label": "Office",
            13        "fieldKey": "office",
            14        "answer": "København Office",
            15        "choice": "688731d4-b6e8-41b9-b171-ac575249501d:244"
            16    }, {
            17        "label": "Department",
            18        "fieldKey": "department",
            19        "answer": "Network",
            20        "choice": "688731d4-b6e8-41b9-b171-ac575249501d:110864"
            21    }, {
            22        "label": "Cost Center",
            23        "fieldKey": "cost-center",
            24        "answer": "Network",
            25        "choice": "688731d4-b6e8-41b9-b171-ac575249501d:112237"
            26    }, {
            27        "label": "Access Card Country",
            28        "fieldKey": "access-card-country",
            29        "answer": "Denmark",
            30        "choice": "688731d4-b6e8-41b9-b171-ac575249501d:111894"
            31    }
            ] 

            We add field key in forms just to be able to use it in automations in a simple way.

             

            $.[?(@.fieldKey=='which-employees-will-have-him-her-as-manager')].choice

            Their is not way to print several values from the response because we cannot use the JSON path expression.

            For ex. Select field "Country" by using JSON path: 

            {{webResponse.body.$.[?(@.fieldKey=='country')].answer}}

             

            Hanna Torany added a comment - When we use the REST API for Jira forms.. We get a response that not possible to work with in Jira Automation.  This made FORMS and Jira Automation not useful together.   [{ 2 "label" : "Fuel Cards" , 3 "fieldKey" : "fuel-cards" , 4 "answer" : "Yes" , 5 "choice" : "14696" 6 }, { 7 "label" : "Country" , 8 "fieldKey" : "country" , 9 "answer" : "Denmark" , 10 "choice" : "688731d4-b6e8-41b9-b171-ac575249501d:111894" 11 }, { 12 "label" : "Office" , 13 "fieldKey" : "office" , 14 "answer" : "København Office" , 15 "choice" : "688731d4-b6e8-41b9-b171-ac575249501d:244" 16 }, { 17 "label" : "Department" , 18 "fieldKey" : "department" , 19 "answer" : "Network" , 20 "choice" : "688731d4-b6e8-41b9-b171-ac575249501d:110864" 21 }, { 22 "label" : "Cost Center" , 23 "fieldKey" : "cost-center" , 24 "answer" : "Network" , 25 "choice" : "688731d4-b6e8-41b9-b171-ac575249501d:112237" 26 }, { 27 "label" : "Access Card Country" , 28 "fieldKey" : "access-card-country" , 29 "answer" : "Denmark" , 30 "choice" : "688731d4-b6e8-41b9-b171-ac575249501d:111894" 31 } ] We add field key in forms just to be able to use it in automations in a simple way.   $. [?(@.fieldKey=='which-employees-will-have-him-her-as-manager')] .choice Their is not way to print several values from the response because we cannot use the JSON path expression. For ex. Select field "Country" by using JSON path:  {{webResponse.body.$.[?(@.fieldKey== 'country' )].answer}}  

              89403358cf11 Charlie Gavey
              jgonzalez2@atlassian.com Jose Luis Gonzalez
              Votes:
              42 Vote for this issue
              Watchers:
              25 Start watching this issue

                Created:
                Updated: