Map Json Data from Integration into Process Variable

I am able query the data that I want from an integration within a process model, but when I try to map the Json results to a CDT process variable, all of the fields are blank.  The keys from the Json dictionary are identical to the names for each field in the CDT. How can I map the Json dictionary into the CDT process variable?

Alternatively, how can I create an expression rule to parse each field from the Json and map each of them to a text process variable? 

the following expression returns all key, value pairs from the Json: a!fromJson(rule!<rule_name>().result.body)

However, the following returns a null value:

a!fromJson(rule!<rule_name>().result.body).keyname1

  Discussion posts and replies are publicly visible

Parents
  • Seems this is occurring due to the way your data from the integration is structured. You might be getting a list of Dictionary as shown in this example.

    What is the output when you cast it? Try this:

    index(cast('type!yourCDT?list', a!fromJson(...result.body), "keyname1", "No Value")


     

  • It says "expected 2 parameters, but found 4 parameters" when including this portion of the expression: , "keyname1", "No Value")

    When I use the following ER I get the following error:

    index(cast('type!{urn:com:appian:types}apiResultsData'(), a!fromJson(rule!API_Results(null).result.body)))

    Expression evaluation error at function 'cast' [line 4]: Could not cast from apiResultsData to Number (Integer). Details: CastInvalidCould not cast from apiResultsData to Number (Integer). Details: CastInvalid

    I am not trying to cast to an integer, as there are only text fields in the Json response and in the CDT. 

    The following is the result from the API Call:

    Raw response body:

    body: "{"args":{"ID":"99887766","File_Name":"PT_1","Type":"PT","Prob":"0.77"},"headers":{"x-forwarded-proto":"https","x-forwarded-port":"443","host":"postman-echo.com","x-amzn-trace-id":"Root=1-5f19cd4a-e32e53040178811afc5c3291","user-agent":"Appian","accept-encoding":"gzip,deflate"},"url":""">postman-echo.com/get error: null (Null) connectedSystem: null (Connected System)

    When I convert JSON to Appian value:

    body Dictionary

      • args Dictionary
          • ID"99887766"(Text)
            • File_Name"PT_1"(Text)
              • Type"PT"(Text)
                • Prob"0.77"(Text)

            • 0
              Certified Lead Developer
              in reply to lukevg

              remove the () after type!{urn:com:appian:types}apiResultsData'() and instead do this: 

              index(cast('type!{urn:com:appian:types}apiResultsData', a!fromJson(rule!API_Results(null).result.body)))

              or if you think you are going to get multiple values then:

              index(cast('type!{urn:com:appian:types}apiResultsData?list', a!fromJson(rule!API_Results(null).result.body)))

            Reply Children