<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.appian.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/discussions/f/integrations/19306/map-json-data-from-integration-into-process-variable</link><description>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</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75678?ContentTypeID=1</link><pubDate>Wed, 29 Jul 2020 16:42:05 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:a9a43869-cf7e-4f5d-85e1-dca5caaf2863</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;&lt;span&gt;What is the output of a!fromJson(rule!API_Results(null).result.body).args)? Seems like this is resulting in a null value. Once you get the correct value from the body you will be able to index into the ID field, File_Name field, etc.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75565?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2020 22:26:20 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:6c9f79d4-485c-451a-ac12-8ffcbf45a570</guid><dc:creator>lukevg</dc:creator><description>&lt;p&gt;Thanks! I&amp;#39;m now able to pass the dictionary through the process model.&lt;/p&gt;
&lt;p&gt;However, I am now stuck on trying to pass a list of dictionaries. The ER above that produced the dictionary I wanted now produces a list of dictionaries that share the same keys.&lt;/p&gt;
&lt;p&gt;When I use the same expression as before to create a custom node output for the integration in the process model, it only returns one dictionary instead of all dictionaries. When i check the array box of each field in the CDT to allow multiple values to be passed in, I get the following error:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;An error occurred while evaluating expression: =pv!APIResults.ID (Invalid index: Cannot index property &amp;#39;ID&amp;#39; of type Text into null value of type apiResultsData?list) (Data Inputs)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75550?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 21:22:18 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:20fe4c72-6913-4cbb-9061-e074538ce0ff</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;Glad that helped! I don&amp;#39;t think a query parameter is going to help you in this specific case since you are already getting the desired result in the result+body. Also, you don&amp;#39;t need casting, just choose&amp;nbsp;&lt;span&gt;&lt;strong&gt;Convert JSON to Appian value&lt;/strong&gt;&amp;nbsp;For&amp;nbsp;&lt;strong&gt;Response Body Parsing &lt;/strong&gt;in your Integration Object configuration&amp;nbsp;and save the output of the Integration rule object to a local or ri variable in a!save().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75548?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 20:16:25 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:b52aae1f-d08b-43db-9540-7702da8d1f49</guid><dc:creator>lukevg</dc:creator><description>&lt;p&gt;Thanks! That was the issue. The dictionary I wanted was nested as the value for the key &amp;quot;args&amp;quot;, so the following query returns what I wanted.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;index(cast(&amp;#39;type!{urn:com:appian:types}apiResultsData&amp;#39;, a!fromJson(rule!API_Results(null).result.body).args))&lt;/p&gt;
&lt;p&gt;Can I add a query parameter of args to the Integration to enter this into the CDT, or is it still best to use casting?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75545?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 19:08:00 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:abfc7487-fe9e-48da-835a-678d68c36b00</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;Based on the raw response posted above your body contains &amp;quot;headers&amp;quot;. This doesn&amp;#39;t seem right. Headers should not be inside the body - see the structure of&amp;nbsp;&lt;a href="https://docs.appian.com/suite/help/20.2/Integration_Object.html#result"&gt;https://docs.appian.com/suite/help/20.2/Integration_Object.html#result&lt;/a&gt;. Once you get the correct body contents with your data you should be able to index into your fields correctly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75543?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 18:49:41 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:571af433-2ea9-4e0f-b3da-bbf31469348a</guid><dc:creator>lukevg</dc:creator><description>&lt;p&gt;Yeah that&amp;#39;s what I&amp;#39;ve been trying to do. It took no effort to create an ER that returns the entire Json response, but have spent many hours trying to parse out individual values of the response or map them to a CDT.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75541?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 18:38:13 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:f926fc2e-4f79-4822-996f-7b34e0fd97c1</guid><dc:creator>Stefan Helzle</dc:creator><description>&lt;p&gt;My recommendation is to encapsulate the integration into an expression rule. There you can do all the data conversion, casting and testing. This is our way of doing integrations. Just put two applications into production which completely run&amp;nbsp;on integrations for data persistence.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75540?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 18:36:48 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:842a99a2-e142-416f-8d47-2d7844fc7e15</guid><dc:creator>lukevg</dc:creator><description>&lt;p&gt;that query executes but returns a null value when I replace &amp;quot;No Data&amp;quot; with a dictionary key&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75539?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 18:30:28 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:aef5c5bb-70c1-40d0-b3a1-dba7c3c50aad</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;&lt;span&gt;index(cast(&amp;#39;type!{urn:com:appian:types}apiResultsData&amp;#39;, a!fromJson(rule!API_Results(null).result.body)), &amp;quot;No Data&amp;quot;)&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75538?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 18:27:22 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:792e8d26-3efd-417d-8284-9cb7559aeb47</guid><dc:creator>lukevg</dc:creator><description>&lt;p&gt;if I run the first query above,&amp;nbsp;&lt;span&gt;I get the following error:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Expression evaluation error at function &amp;#39;index&amp;#39;: Too few parameters for function; expected at least 2 parameters, but found 1 parameters.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;if I run the second query above,&amp;nbsp;the error is:&amp;nbsp; Invalid type for type constructor: apiResultsData?list&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75537?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 17:57:17 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:692b2dc0-04e9-4faa-8140-bbd6ba3aa3a1</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;remove the () after&amp;nbsp;&lt;span&gt;type!{urn:com:appian:types}apiResultsData&amp;#39;() and instead do this:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;index(cast(&amp;#39;type!{urn:com:appian:types}apiResultsData&amp;#39;, a!fromJson(rule!API_Results(null).result.body)))&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;or if you think you are going to get multiple values then:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;index(cast(&amp;#39;type!{urn:com:appian:types}apiResultsData?list&amp;#39;, a!fromJson(rule!API_Results(null).result.body)))&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75536?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 17:53:53 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:2f449a9e-1d31-48de-92ca-25826e433d13</guid><dc:creator>lukevg</dc:creator><description>&lt;p&gt;It says &amp;quot;expected 2 parameters, but found 4 parameters&amp;quot; when including this portion of the expression: , &amp;quot;keyname1&amp;quot;, &amp;quot;No Value&amp;quot;)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I use the following ER I get the following error:&lt;/p&gt;
&lt;p&gt;index(cast(&amp;#39;type!{urn:com:appian:types}apiResultsData&amp;#39;(), a!fromJson(rule!API_Results(null).result.body)))&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Expression evaluation error at function &amp;#39;cast&amp;#39; [line 4]: Could not cast from apiResultsData to Number (Integer). Details: CastInvalidCould not cast from apiResultsData to Number (Integer). Details: CastInvalid&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am not trying to cast to an integer, as there are only text fields in the Json response and in the CDT.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The following is the result from the API Call:&lt;/p&gt;
&lt;p&gt;Raw response body:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;body: &amp;quot;{&amp;quot;args&amp;quot;:{&amp;quot;ID&amp;quot;:&amp;quot;99887766&amp;quot;,&amp;quot;File_Name&amp;quot;:&amp;quot;PT_1&amp;quot;,&amp;quot;Type&amp;quot;:&amp;quot;PT&amp;quot;,&amp;quot;Prob&amp;quot;:&amp;quot;0.77&amp;quot;},&amp;quot;headers&amp;quot;:{&amp;quot;x-forwarded-proto&amp;quot;:&amp;quot;https&amp;quot;,&amp;quot;x-forwarded-port&amp;quot;:&amp;quot;443&amp;quot;,&amp;quot;host&amp;quot;:&amp;quot;postman-echo.com&amp;quot;,&amp;quot;x-amzn-trace-id&amp;quot;:&amp;quot;Root=1-5f19cd4a-e32e53040178811afc5c3291&amp;quot;,&amp;quot;user-agent&amp;quot;:&amp;quot;Appian&amp;quot;,&amp;quot;accept-encoding&amp;quot;:&amp;quot;gzip,deflate&amp;quot;},&amp;quot;url&amp;quot;:&amp;quot;&lt;a href="https://postman-echo.com/get?ID=99887766&amp;amp;File_Name=PT_1&amp;amp;Document_Type=PT&amp;amp;Prob=0.77"&gt;&amp;quot;&amp;quot;&amp;gt;postman-echo.com/get&lt;/a&gt; error: null (Null) connectedSystem: null (Connected System)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When I convert JSON to Appian value:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;i class="SelectableTreeNode---icon SelectableTreeNode---openCloseLink"&gt;&lt;/i&gt;&lt;span class="CollapsibleOutputNode---print_key"&gt;body&amp;nbsp;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_non_value"&gt;Dictionary&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ul class="SelectableTreeNode---componentConfigParam"&gt;&lt;/ul&gt;
&lt;ul class="SelectableTreeNode---nonComponentConfigParam"&gt;
&lt;li class="SelectableTreeNode---selectableTreeNode SelectableTreeNode---open SelectableTreeNode---allow_text_highlighting"&gt;&lt;i class="SelectableTreeNode---icon SelectableTreeNode---openCloseLink"&gt;&lt;/i&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_key"&gt;args&amp;nbsp;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_non_value"&gt;Dictionary&lt;/span&gt;&lt;/span&gt;
&lt;ul class="SelectableTreeNode---componentConfigParam"&gt;&lt;/ul&gt;
&lt;ul class="SelectableTreeNode---nonComponentConfigParam"&gt;
&lt;li class="SelectableTreeNode---selectableTreeNode SelectableTreeNode---leaf SelectableTreeNode---open SelectableTreeNode---allow_text_highlighting"&gt;&lt;i class="SelectableTreeNode---icon SelectableTreeNode---openCloseLink"&gt;&lt;/i&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_key"&gt;ID&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;&amp;quot;99887766&amp;quot;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_element_type"&gt;(Text)&lt;/span&gt;&lt;/span&gt;
&lt;ul class="SelectableTreeNode---componentConfigParam"&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li class="SelectableTreeNode---selectableTreeNode SelectableTreeNode---leaf SelectableTreeNode---open SelectableTreeNode---allow_text_highlighting"&gt;&lt;i class="SelectableTreeNode---icon SelectableTreeNode---openCloseLink"&gt;&lt;/i&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_key"&gt;File_Name&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;&amp;quot;PT_1&amp;quot;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_element_type"&gt;(Text)&lt;/span&gt;&lt;/span&gt;
&lt;ul class="SelectableTreeNode---componentConfigParam"&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li class="SelectableTreeNode---selectableTreeNode SelectableTreeNode---leaf SelectableTreeNode---open SelectableTreeNode---allow_text_highlighting"&gt;&lt;i class="SelectableTreeNode---icon SelectableTreeNode---openCloseLink"&gt;&lt;/i&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_key"&gt;Type&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;&amp;quot;PT&amp;quot;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_element_type"&gt;(Text)&lt;/span&gt;&lt;/span&gt;
&lt;ul class="SelectableTreeNode---componentConfigParam"&gt;&lt;/ul&gt;
&lt;/li&gt;
&lt;li class="SelectableTreeNode---selectableTreeNode SelectableTreeNode---leaf SelectableTreeNode---open SelectableTreeNode---last SelectableTreeNode---allow_text_highlighting"&gt;&lt;i class="SelectableTreeNode---icon SelectableTreeNode---openCloseLink"&gt;&lt;/i&gt;&lt;span&gt;&lt;span class="CollapsibleOutputNode---print_key"&gt;Prob&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_value"&gt;&amp;quot;0.77&amp;quot;&lt;/span&gt;&lt;span class="CollapsibleOutputNode---print_element_type"&gt;(Text)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Map Json Data from Integration into Process Variable</title><link>https://community.appian.com/thread/75535?ContentTypeID=1</link><pubDate>Thu, 23 Jul 2020 17:09:07 GMT</pubDate><guid isPermaLink="false">d3a83456-d57b-489c-a84c-4e8267bb592a:eab0847a-0190-4343-bd4d-e8bccfbb9de4</guid><dc:creator>Omkar Ambardekar</dc:creator><description>&lt;p&gt;Seems this is&amp;nbsp;occurring due to the way your data from the integration is structured. You might be getting a list of Dictionary as shown in &lt;a href="https://docs.appian.com/suite/help/20.2/fnc_system_a_fromjson.html#example"&gt;this example&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;What is the output when you cast it? Try this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;index(cast(&amp;#39;type!yourCDT?list&amp;#39;, a!fromJson(...result.body), &amp;quot;keyname1&amp;quot;, &amp;quot;No Value&amp;quot;)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>